Sign in to follow this  
Followers 0
JAFN

Need help, two layered sort method

5 posts in this topic

#1 ·  Posted (edited)

I have an array, many rows, four columns: Title, Genre, Quantity, UPC

I have a listview filling from the array.

I can sort the listview by clicking on the column headers via SortListView()

However when Genre is clicked I would like the Titles under each subset of Genre to be alphabetical as well.

I hope that was clear.

If anyone knows I'd appreciate the help.

I'm not quite the newbie I was last week, but please dumb it down for me. :unsure:

Thank you.

Edited by JAFN

[size="2"]The second mouse gets the cheese[/size]

Share this post


Link to post
Share on other sites



That is not a trivial operation. You should look at the code for _GUICtrlListView_RegisterSortCallBack() in the GuiListView.au3 UDF.

You would be registering your own custom sort function in place of the _GuiCtrlListView_Sort() that comes with the UDF.

:unsure:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

That is not a trivial operation. You should look at the code for _GUICtrlListView_RegisterSortCallBack() in the GuiListView.au3 UDF.

You would be registering your own custom sort function in place of the _GuiCtrlListView_Sort() that comes with the UDF.

:unsure:

When I cut my teeth on computers COBoL was king, monitors were paper and input was punch cards.

Now my mind is going and my eyes with it. I've recently started coding again as a way to keep my mind active and hopefully prolong these periods of clarity.

All that is explain my I take some prise at having completed this latest hurdle.

The code is specific to my situation and I haven't supplied the array data code. But I wanted to show my solution.

#Include <Array.au3>
#Include <File.au3>

; $Data is a 2D array with 4 columns
; $Genre is the column to index by (0 based)
; $Title is the column to subindex (0 based)

    Local $Genre = 3
    Local $Title = 0
    Local $TempData = $Data
    $Local GenreBox = _ArrayUnique($Data, $Genre) ; each category in Genrebox
    _ArraySort($GenreBox, 0)    ; sort the genres
    _ArraySort($Data, 0, 0, 0, $Genre)

    Local $end = 0
    Local $strt= 0
    For $GenreItem = 1 To UBound($GenreBox)-1
        For $a = $strt to UBound($data)-1
            If $data[$a][3] > $Genrebox[$GenreItem] Then ExitLoop
        Next
        $end = $a - 1
        _ArraySort($Data, 0, $strt, $end, $Title)
        $strt = $a

    Next

_ArrayDisplay($Data, "alpha by genre")

Now I can sleep :>


[size="2"]The second mouse gets the cheese[/size]

Share this post


Link to post
Share on other sites

I thought you were trying to tie that to a ListView column header click.

:unsure:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I thought you were trying to tie that to a ListView column header click.

:unsure:

That part I already had had.


[size="2"]The second mouse gets the cheese[/size]

Share this post


Link to post
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
Sign in to follow this  
Followers 0