Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Sort numeric files in Windows

Sort numeric files in Windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
sortnumeric fileswindowsqdir
3 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DonnD Offline
    DonnD Offline
    Donn
    wrote on last edited by
    #1

    I have a list of files like:

    007_601_1
    007_601_2
    007_601_3
    007_601_10
    007_601_11
    007_601_12
    

    When I sort it using QDir::Name I get the following order:

    007_601_1
    007_601_10
    007_601_11
    007_601_12
    007_601_2
    007_601_3
    

    However, I need the order as mentioned in the first file list. Is there a way to sort like this or do I need to write my own piece of code which does it?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by alex_malyu
      #2

      AFAIK functions like QDir::entryList sort file names only in alphabetical orders.

      If you want to achieve different results you will need to write your own sorting code.

      1 Reply Last reply
      0
      • DonnD Offline
        DonnD Offline
        Donn
        wrote on last edited by
        #3

        Is QCollator::compare a good option for this? I mean, I simply implement a sorting algorithm based on the result from QCollator::compare. Usually the number of files will be limited to ~3000.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved