Page 1 of 1

List View Sort

PostPosted: Thu Apr 13, 2017 1:52 pm
by ingibekk
Hello there,

does someone have a script available that sorts a list view in a specific order based on values in a specific column ?

Similar to what you do in every other spreadsheet application.

Cheers,
IB

Re: List View Sort

PostPosted: Thu Apr 20, 2017 1:07 pm
by Janina Baltaziewicz
Hi IB,

That's indeed a tough one.
I don't have a script ready, but I think it should work when you load all cell values of the respective column into a list variable with "VGetListViewCell" and a for-loop, and sort this one with "VArraySort".
You could then use one of the "VGetListViewSearch..." commands to retrieve all values of the whole row and set those values again to the correct cells (where the row number would be the index of the item in the sorted list) with "WDListViewSetCell".

I think the best workflow would be to sort the column values, then read out each row and buffer the cell values in list variables, and finally overwrite the ListView rows according to the new sorting.
Depending on your setup, this might even be possible by using only local variables.


Does this approach help you?

Cheers,

Janina

Re: List View Sort

PostPosted: Thu Apr 20, 2017 1:36 pm
by ingibekk
Hi Janina,

thanks for the reply.

This could definitely work, it's a list with only 2 columns (Name and Score) where I need to sort by the lowest score.

I haven't used for loops a lot but I better give it a go, thanks for the tip!

Cheers,
Ingi Bekk