1

I have data of students in Guajarati in MySQL database and I want to sort the roll numbers while fetching data from database but roll number is in Guajarati so it is not sorting properly. I have even tried ORDER BY rollno*1 ASC while fetching data from database but it doesn't work is there any way I can sort it like normal English numbers.

Smit shah
  • 35
  • 8
  • Does this answer your question? [How to store the data in unicode in hindi language](https://stackoverflow.com/questions/12435867/how-to-store-the-data-in-unicode-in-hindi-language) – Rohit Gupta Oct 07 '22 at 04:33
  • No, actually i can already store the characters in database without any problem what i want is to sort the Guajarati numbers in the proper way. I have tried sorting it in normal way but it sorts like this 1,10,11,...19,2,20,21,22,...29,3,30........ – Smit shah Oct 10 '22 at 16:47
  • hey I found the solution and added it as a answer – Smit shah Oct 14 '22 at 17:46

1 Answers1

1

I have found the solution for this fortunately.

Instead of ORDER BY rollno*1 ASC I did this ORDER BY LENGTH(rollno),rollno ASC

This will do the sorting for Unicode.

First it will do the sorting by length of string and then it will sort by Unicode so this will do the perfect work because other language numbers are not numbers in programming language or MySQL so we need to do sorting like this.

Smit shah
  • 35
  • 8