Skip to content

[Question] orderBy() with natural sorting #2025

Open
@roman-briazgalov

Description

@roman-briazgalov

Hi!
First of all thank you very much for this library! It's really useful and convenient!
I cannot understand one thing: how should i use orderBy().
So my query is here:

return (new Elements())
            ->newQuery()
            ->where('user_id', $user_id)
            ->where('child', false)
            ->where('in_trash', false)
            ->orderBy('title')
            ->paginate(10);

The result of this query is:

12312123
AZaz
WQER
ZXC
az
test
zxc

As you can see the sorting is not 'natural'.

I need to make the query that would return this items with this order:

12312123
AZaz
az
test
WQER
ZXC
zxc

I studied in detail this issue #148
But anything i have tried didn't help me.

I would be really appreciated if you tell me how can could i make the needed sorting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions