order search result by metadata

I want to order search result by its metadata, for example "price"

how to do this ?

 

this is the original function in search_hooks.php,

function search_objects_hook($hook, $type, $value, $params) {

    $db_prefix = elgg_get_config('dbprefix');

    $join = "JOIN {$db_prefix}objects_entity oe ON e.guid = oe.guid";
    $params['joins'] = array($join);
    $fields = array('title', 'description');

    $where = search_get_where_sql('oe', $fields, $params);

    $params['wheres'] = array($where);
    $params['count'] = TRUE;
    $count = elgg_get_entities($params);
    
    // no need to continue if nothing here.
    if (!$count) {
        return array('entities' => array(), 'count' => $count);
    }
    
    $params['count'] = FALSE;
    $params['order_by'] = search_get_order_by_sql('e', 'oe', $params['sort'], $params['order']);
    $params['preload_owners'] = true;
    $entities = elgg_get_entities($params);

    // add the volatile data for why these entities have been returned.
    foreach ($entities as $entity) {
        $title = search_get_highlighted_relevant_substrings($entity->title, $params['query']);
        $entity->setVolatileData('search_matched_title', $title);

        $desc = search_get_highlighted_relevant_substrings($entity->description, $params['query']);
        $entity->setVolatileData('search_matched_description', $desc);
    }

    return array(
        'entities' => $entities,
        'count' => $count,
    );
}

what should i change if i want to order by entity "price" ?