Results 1 to 2 of 2

Thread: Khmer language words sorting

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Location
    Jordan, and UAE
    Posts
    55
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Khmer language words sorting

    Good day

    I'm trying to sort a list of Khmer words, but so far I'm not successful. I'm using UTF-8 and qSort to do the job, but there is something wrong, or something missing.
    (the below code worked ok for English and French)

    Qt Code:
    1. bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
    2. {
    3. return s1.trimmed().toLower() < s2.trimmed().toLower();
    4. }
    5.  
    6. void mySort(QStringList &list)
    7. {
    8. qDebug() << "unsorted list: " << list;
    9. qSort(list.begin(), list.end(), caseInsensitiveLessThan);
    10. qDebug() << " sorted list: " << list;
    11. }
    To copy to clipboard, switch view to plain text mode 

    This is an example list I have that is sorted, and should not be resorted when using the sort code.

    ក1, ក៏2, កក3, កក់4, កករ5, កកាត6, កកាយ7, áž€áž€áž·áž…áž€áž€áž»á …8, កកិត9, កកិល10

    but when using my sorting code (above), I'm getting this list.

    ក1, កក3, កករ5, កកាត6, កកាយ7, áž€áž€áž·áž…áž€áž€áž»á …8, កកិត9, កកិល10, កក់4, ក៏2

    Any suggestions are most welcomed?

    Thank you

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Khmer language words sorting

    From documentation of QString:

    bool QString:perator< ( const QString & other ) const
    Returns true if this string is lexically less than string other; otherwise returns false.
    The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would expect. Consider sorting user-interface strings using the QString::localeAwareCompare() function.
    Don't write a post just to thank someone, use "Thanks" button.

Similar Threads

  1. Replies: 1
    Last Post: 24th August 2011, 13:49
  2. Khmer Unicode Problem with Qt 4.7/QTextEdit
    By lsvichet in forum Newbie
    Replies: 4
    Last Post: 23rd May 2011, 20:34
  3. Highlighting individual words of a sentence
    By kellorooney in forum Newbie
    Replies: 1
    Last Post: 16th April 2010, 04:51
  4. Adding 3 words to Button with specified length betwwen words
    By chikkireddi in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2007, 11:08
  5. how to color certain words in a textedit
    By chandrabose.s in forum Newbie
    Replies: 12
    Last Post: 15th March 2006, 09:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.