I have a JS array in following structure:
Array(
[0] => Array(
reference : "8926"
name : "xyz1"
id_product : "78"
)
[1] => Array(
reference : "11588"
name : "xyz2"
id_product : "21"
)
[2] => Array(
reference : "119"
name : "xyz3"
id_product : "135"
)
)
I needed to sort this array using the reference key, I have done it using multisort function;
But the problem is : even though reference is numeric but in the array structure it is defined as string and hence instead of sorting like:
119, 8926, 11588 it is sorting it like 11588 119 8926, i.e., like string.
I cannot re-structure the array because I receive it through an API, is there anyway to sort it numerically without having to recreate it in numeric data type separately (because I have to pass the array forward in same format & hence double-conversion will make the script hectic)?
PS - Current sorting (non-numeric) is done using this function.