I m using Devnagari fonts in my application. Each English key in keyboard represent certain character in Devnagari. For example my name is Sabin in English but when i use devnagari font it would be “;lag” without quotes. And records are saved in this way in the database. Now i m having problem in sorting records.
In devnagari first comes are Devnagari vowels and then devnagari alphabets. Like
c,cf,O,O{,p,pm,…… [each one separated by comma]
Then devnagari alphabets equivalent starting from first,
s,v,u,#,… and so on [each one separated by comma].
Problem I m having is sorting names alphabetically in devnagari. Any idea will be highly appreciated. Thanks!
Edit: The array returned as following which I need to use usort function.
Array
(
[0] => stdClass Object
(
[user_id] => NLK32437
[first_name] => ;lag
[last_name] => %]qL
[email_address] => test1@msn.com
[mobile_number] => 9834874582
[description] => g]kfn
[date_joined] => 08-AUG-12
[status] => 1
[username] => user1
[userpassword] => 691f9298642af07c2d6ea8fef56074201e077b34
)
[1] => stdClass Object
(
[user_id] => NLK32435
[first_name] => clgn
[last_name] => zdf{
[email_address] => test2@msn.com
[mobile_number] => 984134354
[description] => g]kfn
[date_joined] => 08-AUG-12
[status] => 1
[username] => user2
[userpassword] => 0e025eade868b4b481f41ff7449bc1967261e170
)
)
You are abusing text encodings. You are saving your text as codepoints that are meant for other things, and are only using a font that renders the originally English letters as something else. This is entirely the wrong way to go about it.
There are several encodings which let you save Devanagari as actual Devanagari characters. It’s supported in Unicode. Save the text as actual Devanagari characters that they were meant to be, don’t overload existing English code points and depend on a broken font. Then you’ll get sorting functionality and many other things by anything that supports Unicode.
A simple
usortexample nonetheless: