We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Mongo DB - natural sort

Hi. I have problem with MongoDB sorting. Sort is sorting data, but not naturally. Words with capital letter are always before rest of words. I Found in Mongo Documentation that there is a rule for natural sorting, but i can't find example for Phalcon.

My code:

public static function getActivityActions($id) {
    $actions = Action::find(array(
        'conditions' => array('activity_id' => $id),
        'sort' => array('name' => 1)
    ));

    return $actions;
}

Please help Me :)

edited Sep '17
$actions = Action::find(array(
    'conditions' => array('activity_id' => $id),
    'sort' => array('name' => 1)
));

return natsort($actions);