Jump to content

FileListToArrayRec sort by Filenames?


Shocker
 Share

Recommended Posts

Hi there,

use FileListToArrayRec(1,1,1,2) to find 2 Files from different Folders. Array returns

[0]|2
[1]|D:\MyProg\Folder\1\xyz123.txt
[2]|D:\MyProg\Folder\2\xyz124.txt

although second Filename is bigger than first one. Is there a simple way to correct that or only with _ArrayColInsert(), String splitting, _Arraysort(), _ArrayColDelete() etc.?

 

Thx 4 reply :thumbsup:

Link to comment
Share on other sites

I am not super familiar with this function and not sure I fully understand your question but looking at your function (which we'll assume starts with a path that you omitted) the last parameter is sort.  I would expect 123 to come before 124 if you sort the results.   If you want 124 to come before 123 try turning off sorting by using 0 for last parameter instead of 2.

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

  • Moderators

Shocker,

I wrote the _FileListToArrayRec UDF and what you see returned is exactly what I would expect to see when you have set the $iSort parameter. I am unsure what you mean by:

Quote

second Filename is bigger than first one

as the UDF sorts alphabetically and thus folder 1 comes before folder 2 - the filenames are only sorted inside their respective folders.  So if you want to sort on filename regardless of the earlier path, you will indeed have to do something like you suggested in the OP.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

  Skysnake,

Quote
$iSort  - [optional] Sort results in alphabetical and depth order

When sorted, the UDF returns the list sorted as if you had copied it from Explorer - each level of the path is sorted separately and then the contents of that level are further sorted. So you get a final result like this:

Folder A
--------- File A
--------- File B
Folder B
--------- SubFolder A
--------------------- File A
--------------------- File B
--------- SubFolder B
--------------------- File A
--------------------- File B
Folder C
--------- File A
--------- File B

So all the elements of the path are taken into consideration - which is why in the above example Folder 1 comes before Folder 2. As there is only a single file within each of them there is no further sorting required - if there were more then the files within each folder would be sorted separately.

Clearer?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...