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
Forum Updated to NodeBB v4.3 + New Features

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.
  • D Offline
    D Offline
    Donn
    wrote on 30 Mar 2016, 19:17 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 30 Mar 2016, 19:29 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
      • D Offline
        D Offline
        Donn
        wrote on 30 Mar 2016, 19:34 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

        1/3

        30 Mar 2016, 19:17

        • Login

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