Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-108756

QCollatorSortKey gives wrong compare result

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.10
    • None
    • Qt 5.15.10 msvc2019_64 compiler version installed
    • Windows
    • 21

    Description

      QCollator with numericMode generates QCollatorSortKey that have differ results in compare function that QCollator that generates that keys.

      The easiest example of that:

      mCollator.setNumericMode(true);
      auto result = mCollator.compare("00", "10"); //-1 ok
      QCollatorSortKey key1 = mCollator.sortKey("00");
      QCollatorSortKey key2 = mCollator.sortKey("10");
      
      auto result2 = mCollator.compare("9", "10"); // -1 ok
      QCollatorSortKey key3 = mCollator.sortKey("9");
      QCollatorSortKey key4 = mCollator.sortKey("10");
      
      auto result3 = mCollator.compare("99", "100"); // -1 ok
      QCollatorSortKey key5 = mCollator.sortKey("99");
      QCollatorSortKey key6 = mCollator.sortKey("100");
      
      bool result4 = key1 < key2; //false wrong
      bool result5 = key3 < key4; //true  ok
      bool result6 = key5 < key6; //false wrong

      It seems that that QCollatorSortKey generated from QCollator not works properly when setNumericMode is set to true.

       

      I attached some example of result after sorting, the range was from 0 to 35000

       

      Attachments

        Issue Links

          Activity

            People

              cnn Qt Core & Network
              zloty Paweł Srebrny
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: