tommeke228 Posted January 9, 2015 Posted January 9, 2015 Hi there Here's a picture of my listview loaded in with FileFindFirstFile and here with _FileListToArray How can i make that it sorts perfectly from 1 till 12 ? Putting numbers in the filename doesnt work, it doesn't work without it... pff is there an easy solution ? grtz Tom
Moderators Melba23 Posted January 9, 2015 Moderators Posted January 9, 2015 tommeke228, is there an easy solution ?In short - no. As this recent thread showed. >M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
tommeke228 Posted January 9, 2015 Author Posted January 9, 2015 pff thanks gona search a solution because it needs to be fixed ;p (will post it then) grtz tom
Moderators Melba23 Posted January 9, 2015 Moderators Posted January 9, 2015 tommeke228,If these filenames are created by you, then forcing the leading number into a fixed format with leading zeroes will work. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jdelaney Posted January 9, 2015 Posted January 9, 2015 (edited) You can re-dim the array to add a second dimention...use a regexp to grab the leading numbers, and convert them to integers...then sort by that new column...edit: repopulate back to the 1d array. #include <Array.au3> Local $a[3]=["1 something", "11 something2", "2 something3"] _ArrayDisplay($a) ; since the redim doesn't work when changing dimentions, create a new one...quicker Local $a2[UBound($a)][2] For $i = 0 To UBound($a2)-1 $a2[$i][0] = $a[$i] $a2[$i][1] = Number(StringRegExpReplace($a[$i],"(\d+)(.*)","\1")) Next _ArraySort($a2,0,0,0,1) For $i = 0 To UBound($a)-1 $a[$i] = $a2[$i][0] Next $a2 = "" _ArrayDisplay($a) Edited January 9, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Moderators Solution SmOke_N Posted January 9, 2015 Moderators Solution Posted January 9, 2015 (edited) As Melba said, leading zeros with StringFormat (I usually use 6) solves the issue nicely for future issues. This situation is easily fixed though, just using converting to int(). IMO, this is not a cure all though, doesn't take care of numbers throughout the string. expandcollapse popup#include <Array.au3> Global $gaOrignal[] = [ _ "1 Monday 5 January 2015_6u_7u", "10 Tuesday 6 January 2015_4-5", _ "11 Tuesday 6 January 2015_17u15-18u15", "12 Wednesday 7 January 2015_6u15-7u15", _ "2 Monday 5 January 2015_7u15-9u15", "3 Monday 5 January 2015_9u30-12u00", _ "4 Monday 5 January 2015_12u30-16u00", "5 Monday 5 January 2015_16u-17u", _ "6 Tuesday 6 January 2015_6u15-7u15", "7 Tuesday 6 January 2015_7u15-9u15", _ "8 Tuesday 6 January 2015_9u30-12", "9 Tuesday 6 January 2015_12u30-17u15"] _ArrayDisplay($gaOrignal) _mySimple1DArrSortSolution($gaOrignal) _ArrayDisplay($gaOrignal) Func _mySimple1DArrSortSolution(ByRef $aArr, $iDesc = 0, $iStart = 0, $iEnd = 0) If Not IsArray($aArr) Then Return SetError(1, 0, 0) If UBound($aArr, 2) Then Return SetError(2, 0, 0) Local $iUB = UBound($aArr) If $iEnd < $iStart Or $iEnd > ($iUB - 1) Then Return SetError(3, 0, 0) $iEnd = (IsKeyword($iEnd) Or $iEnd < 1) ? $iUB - 1 : $iEnd Local $aTmp[$iUB][2] For $i = $iStart To $iEnd $aTmp[$i][0] = $aArr[$i] $aTmp[$i][1] = Int($aArr[$i]) Next _ArraySort($aTmp, $iDesc, $iStart, $iEnd, 1) For $i = $iStart To $iEnd $aArr[$i] = $aTmp[$i][0] Next EndFunc Edit: Oops, didn't see jdelaney posted. Edited January 9, 2015 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
jdelaney Posted January 9, 2015 Posted January 9, 2015 Almost exactly the same technique...I just used a regexp to grab the first digits, instead of grabbing all of them. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
tommeke228 Posted January 10, 2015 Author Posted January 10, 2015 (edited) thankyou so much guys !!!! :thumbsup: Edited January 10, 2015 by tommeke228
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now