I am working on the website in which I want to sort everything on the basis of customer_name (which is the 1st column from the table)..
Below is my query in php code I have:
.....
.....
$y = isset($filters['items']['yaxis']) ? $filters['items']['yaxis'] : null;
$x = isset($filters['items']['xaxis']) ? $filters['items']['xaxis'] : null;
switch ($y) {
case 'customer_name':
$query->order( columns: $y . ' ' . (strtoupper($x) == 'DESC' ? 'DESC' : 'ASC'));
break;
}
Problem Statement:
I am wondering what changes I should make in the SQL Query above so that it sorts everything on the basis of customer_name
only but sorting should follow the logic as mentioned below:
let arr = [
'1 Hello',
'2 Hello',
'3 Hello',
'4 Hello',
';1',
'z',
'%1',
'110 Hello',
'100 Hello',
'a',
'Z',
'00',
'21 Hello',
'9 Hello',
'13 Hello',
'10000 Hello',
'0 Hello',
'A'
];
arr.sort( (a, b) => {
return a.localeCompare(b, 'en', {
numeric: true
})
} ).forEach( ml => { console.log(ml) });
The above Javascript is printing the following o/p:
;1
%1
00
0 Hello
1 Hello
2 Hello
3 Hello
4 Hello
9 Hello
13 Hello
21 Hello
100 Hello
110 Hello
10000 Hello
a
A
z
Z
=> undefined
So I want to sort all the data on customer_name
in my above php file but in Lexicographical order just like my above javascript is doing.