I am using Laravel 7.
I am having some problems with sorting while using Laravel 7.
To put it briefly. My table has a json column.
Example column name: "jsonData" json data:
$data1 =
{
"rank":12,
"value":"test",
}
$data2 =
{
"rank":105,
"value":"test-2",
}
According to these data, the following query is made.
DB::table('tablename')->orderBy('jsonData->rank', 'ASC')->get();
While the output I get should be 12 - 105, normally from small to large. When I print the data here, it becomes 105 - 12.
Another example of sorting like this:
1
1
10
100
108
113
12
120
1231885
13631
144
You may have noticed how absurd this is. I have done a lot of research on how to solve this. But I could not come to a conclusion.