How To Sort Foreign Characters ? Unicode Data ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
phpbaby2009
Forum Commoner
Posts: 31
Joined: Sun Nov 16, 2008 8:20 pm

How To Sort Foreign Characters ? Unicode Data ??

Post by phpbaby2009 »

I looked everywhere, but this seems to have not been solved. Can you please... please help.

given, [data has nepali words which are read from a UTF8 file.]

$varToSort[0]="के छ kay chha";
$varToSort[1]="गयो gayo";
$varToSort[2]="खराया kharayo";
$varToSort[3]="कुमारी kumari";
$varToSort[4]="पड pada";

since the sort function won't be able to handle none ASCII characters, (can it ?) I thought I could pass the entire array/data through a loop and sort based on a pattern that's define in another array. So I have another array where the patterns are.

$NepaliSortPattern=Array (
"क ka",
"के kay",
"कु ku",
"की key",
"कै kai",
"ख kha",
"खे khay",
"खु khu",
"खै khai",
"ग ga",
"गु gu",
"गै gai",
"गी gee",
"गा ga"
)
Key of Array represents the order in which data needs to be sorted and the array is only a part of the Nepali Alphabets. Nepali language has over 36 alpha but each alpha can have many sub alpha that needs to be added so the sorting is proper. I will add all of them here so it might useful to others.

Required : A loop that compares first few characters of the $varToSort with Each NepaliSortPattern starting from the first array to the last. If Unicode Characters are too difficult to work with, we can compare the strings written in English after the Nepali.

How to create that beautiful loop, compare, and sort.... Please. I think it's not possible.

Any SMART dude out there ? :banghead: धेरै धेरै धन्यवाद धेरै धेरै धन्यवाद धेरै धेरै धन्यवाद धेरै धेरै धन्यवाद -- That's in Nepali meaning thank you so much.

please help and i am gonna write your name in BEAUTIFULLY in Nepali.... Guys believe me. I couldn't find a solution to this on the web and I am sure many other languages could be sorted using this technique where the author will only need to define the sort pattern. Please help You Smart !
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: How To Sort Foreign Characters ? Unicode Data ??

Post by Jade »

There are a lot of good references in the comments section of the arsort here: http://us3.php.net/asort
User avatar
phpbaby2009
Forum Commoner
Posts: 31
Joined: Sun Nov 16, 2008 8:20 pm

Re: How To Sort Foreign Characters ? Unicode Data ??

Post by phpbaby2009 »

Jade wrote:There are a lot of good references in the comments section of the arsort here: http://us3.php.net/asort

Jade, thanks. but all i am asking is a loop. how to write friend. could you help ? :drunk:
Post Reply