Jump to content

ArrayMultiColSort -New Release 06 April 2019


Melba23
 Share

Recommended Posts

  • Moderators

dmob,

Mea culpa! Thanks for that - it will be fixed in the next release.

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

On 5/9/2020 at 6:41 AM, Melba23 said:

A sensible suggestion which could have a wider application. Please try this Beta version of the UDF and see if it meets with your requirements...

M23

I tried it out, and that works just fine for my application, so thanks for taking some time. I agree that RegExs can certainly be a bit of a pain :P

Looking forward to more updates and scripts from you, love your stuff.

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

  • Moderators

Hi all,

I have added the possibility to search for other than a full match when sorting the array. There is a new parameter to determine which sort of match to make:

;                 $iMatch    - If sorting on strings, string match mode (default = 0 - full match)
;                                 - 0 = Full match of string with element
;                                 - 1 = Partial (StringInStr) match of string with element
;                                 - 2 = RegEx match with element - user must supply valid Regex patterns
;                                     Note: The selected mode applies to ALL strings matched within ALL columns

 If anyone would care to test this new Beta I would be most grateful: 

M23

 

Edited by Melba23
Beta code removed

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

Hi Melba23 :)
This new feature ($iMatch) looks very interesting, gonna test if for sure.

Meanwhile, I was wondering if the "string of items" could be reduced to a single item without producing an error. For example, here is the line found in the example script (1st page of this thread) :

Global $aSortData = [ _
    [0, 1], _
    [1, 0], _
    [2, "SSSSS,QQQQQ,PPPPP,RRRRR"], _
    [3, 0]]

As soon as you change the string to what follows, you'll get @error = 2 and @extended = 1 :

Global $aSortData = [ _
    [0, 1], _
    [1, 0], _
    [2, "SSSSS"], _
    [3, 0]]

imho one should be able to sort the column with "SSSSS" rows placed first, no matter the other rows stay unsorted. I'm asking this because a search for a partial match, like in the script below, would produce the same error :

#include "ArrayMultiColSort_Mod.au3"

Global $aArray[5][3] =  [ _
    [5, "hello", "there"], _
    [5, "bonjour", "ici"], _
    [1, "bye", "hey"], _
    [5, "autoit", "good"], _
    [5, "great", "fantastic"]]

_ArrayDisplay($aArray, "before")

Global  $iSortDirection = 0 ; 0 = ascending, 1 = descending, or string : for last column in $aSortData[][]

Global $aSortData[][] = [ _
    [0, $iSortDirection], _
    [2, "oo"]]

_ArrayMultiColSort($aArray, $aSortData, 0, 0, 1) ; last 1 = Partial (StringInStr) match of string with element
If @error Then MsgBox(0,"_ArrayMultiColSort", "@error = " & @error & "    @extended = " & @extended)

_ArrayDisplay($aArray, "after")

In this example, one could get a correct result by typing what follows... not sure it's the good way :

"oo," & chr(255)

 

Link to comment
Share on other sites

  • Moderators

pixelsearch,

I see what you mean - I will look into how it might be done.

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

  • 3 weeks later...
  • Moderators

pixelsearch,

My apologies - I did not realise I had not posted an amended version which does what you require. Now you only get the error if you ask the UDF to sort using a blank string for a column.

Please try this out and let me know if it works for you: ArrayMultiColSort_Mod.au3

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

Thanks Melba23 :)
Just tried the amended version, it seems to work fine using the following script, which is based on "partial match of string"

#include "ArrayMultiColSort_Mod.au3"

Global $aArray[15][3] =  [ _
    [10, "Left side", "Combo 10"], _
    [11, "Middle facing", "Combo 11"], _
    [12, "Right side", "Flat 12"], _
    [15, "Left side", "Duplex 15"], _
    [5, "Middle facing", "Duplex 5"], _
    [14, "Middle facing", "Flat 14"], _
    [3, "Middle facing", "Duplex 3"], _
    [7, "Right side", "Duplex 7"], _
    [6, "Left side", "Flat 6"], _
    [13, "Right side", "Combo 13"], _
    [8, "Right side", "Combo 8"], _
    [1, "Middle facing", "Flat 1"], _
    [9, "Left side", "Duplex 9"], _
    [4, "Left side", "Duplex 4"], _
    [2, "Right side", "Duplex 2"]]

_ArrayDisplay($aArray, "Unsorted")

Global $aSortData[][] = [ _
    [1, "Middle"]]
_ArrayMultiColSort($aArray, $aSortData, 0, 0, 1) ; last 1 = Partial (StringInStr) match of string with element
If @error Then MsgBox(0,"_ArrayMultiColSort Test #1", "@error = " & @error & "    @extended = " & @extended)
_ArrayDisplay($aArray, "Middle")

Global $aSortData[][] = [ _
    [1, "Middle"], _
    [2, "Duplex"]]
_ArrayMultiColSort($aArray, $aSortData, 0, 0, 1) ; last 1 = Partial (StringInStr) match of string with element
If @error Then MsgBox(0,"_ArrayMultiColSort Test #2", "@error = " & @error & "    @extended = " & @extended)
_ArrayDisplay($aArray, "Middle & Duplex")

Global $aSortData[][] = [ _
    [1, "Middle"], _
    [2, "Duplex,Flat"]]
_ArrayMultiColSort($aArray, $aSortData, 0, 0, 1) ; last 1 = Partial (StringInStr) match of string with element
If @error Then MsgBox(0,"_ArrayMultiColSort Test #3", "@error = " & @error & "    @extended = " & @extended)
_ArrayDisplay($aArray, "Middle & Duplex,Flat")

Now I'm gonna try the RegExp part ($iMatch = 2, "RegEx match with element")
Maybe one should avoid to use the comma inside the RegEx pattern, or it will be considered as a separator within the "sort order" column of the parameter $aSortData ?

Link to comment
Share on other sites

  • Moderators

pixelsearch,

At present a comma in the RegEx would be considered as a delimiter. I am not too concerned about that at the moment - unless someone else can convince me otherwise!

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

  • 1 year later...
  • Moderators

rlvitorino,

You have the "numbers" stored in string datatypes - so they are sorted alphabetically. Use Num() to convert them to numeric datatypes and they will sort as you wish.

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


 

 

I convert to number before adding array. I've concatenated another column to addArray

Number(StringStripWS($Match[0],$STR_STRIPALL))
_ArrayAdd($aResult ,Number(StringStripWS($Match[0],$STR_STRIPALL)) & "|" & StringStripWS(StringReplace(StringReplace(StringReplace($aFiles[$i],"result ",""),"(",""),").png",""), $STR_STRIPALL))
_ArrayDisplay($aResult,"")

 

Edited by Melba23
Amended font and removed images
Link to comment
Share on other sites

PLease stop using giant font, that won't make your case easier.

33 minutes ago, rlvitorino said:

Number(StringStripWS($Match[0],$STR_STRIPALL)) & "|" &

You do use Number() but you concatenate that to "|" and some other string, so everything in the added row is a string.

Loop thru your array and convert every numeric cells using Number() explicitely.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • Moderators

rlvitorino,

What jchd said!

M23

P.S. And please stop posting images and using giant fonts.

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

  • 4 months later...
  • 6 months later...

Hello. I just worked with function _ArrayMultiColSort() and found that it doesn't sort specified column properly if there is mixed datatypes (like strings and numbers). See example:

Global $aTest[][] = [ _
    [ "a","1", 1] _
    ,[ "b","4", 1] _
    ,[ "a","3", "1_test"] _
    ,[ "a","1", 2] _
    ,[ "b","6", "1_test"] _
    ,[ "a","8", 1] _
    ,[ "b","1", 1] _
    ,[ "b","0", "1_test"] _
    ,[ "a","1", 1] _
    ,[ "b","1", 2] _
    ,[ "b","1", "1_test"] _
    ,[ "a","5", 1] _
    ,[ "b","6", 2] _
    ,[ "b","7", "1_test"] _
    ,[ "a","8", 1] _
    ,[ "b","8", 1] _
    ,[ "b","8", "1_test"] _
    ,[ "a","1", 1] _
    ,[ "b","2", 2] _
    ]
_ArrayDisplay($aTest, "before sorting")
Global $g_aSortData[][] = [ [0, 0], [2, 0], [1, 0] ]
_ArrayMultiColSort($aTest, $g_aSortData)
_ArrayDisplay($aTest, "after sorting")

to fix it i had to convert all cells to string

Global $aTest[][] = [ _
    [ "a","1", 1] _
    ,[ "b","4", 1] _
    ,[ "a","3", "1_test"] _
    ,[ "a","1", 2] _
    ,[ "b","6", "1_test"] _
    ,[ "a","8", 1] _
    ,[ "b","1", 1] _
    ,[ "b","0", "1_test"] _
    ,[ "a","1", 1] _
    ,[ "b","1", 2] _
    ,[ "b","1", "1_test"] _
    ,[ "a","5", 1] _
    ,[ "b","6", 2] _
    ,[ "b","7", "1_test"] _
    ,[ "a","8", 1] _
    ,[ "b","8", 1] _
    ,[ "b","8", "1_test"] _
    ,[ "a","1", 1] _
    ,[ "b","2", 2] _
    ]
_ArrayDisplay($aTest, "before sorting")
Global $g_aSortData[][] = [ [0, 0], [2, 0], [1, 0] ]

for $x=0 to Ubound($aTest) - 1
    for $y=0 to Ubound($aTest, 2) - 1
        $aTest[$x][$y] = String($aTest[$x][$y])
    Next
Next


_ArrayMultiColSort($aTest, $g_aSortData)
_ArrayDisplay($aTest, "after sorting")

I don't know if this is a bug or this is ok. Just giving you my feedback.

Link to comment
Share on other sites

  • Moderators

mandriospo,

Quote

it doesn't sort specified column properly if there is mixed datatypes (like strings and numbers)

That is a "feature" of the array sort algorithm in the standard Array library which is used in the UDF - so no bug. But thanks for taking the time to point it out.

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...