Sorting cards

William Prothero prothero at earthlearningsolutions.org
Thu Dec 30 16:14:19 EST 2021


It might be less work to just implement your own sorting code. I’ve found them pretty easy to implement. A bubble sort is very simple, but inefficient for a large number of items to sort. If you have a lot of cards, you would want to use a more efficient algorithm. Check out the link below if you are interested.

https://en.wikipedia.org/wiki/Sorting_algorithm

Good luck,
Bill P

Sent from my iPad

> On Dec 30, 2021, at 12:53 PM, Quentin Long via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> sez J. Landman Gay:> I am converting an old stack to LC and it needs to sort cards by one of two fields. LC does 
>>  stable sorts, so if I sort by field 1 it works, and then if I sort later by field 2 it retains 
>>  the original sort and does a sub-sort. I don't want that. What's the best way to ignore the 
>>  previous sort order?
> 
> Hmmm… how about this?
> 1. Give each card a custom property, call it "SortValue" or some such.2. *Before* the first sort: Go thru each card and set the SortValue of each card to an integer, incrementing the number by 1 with each new card.3. *After* the first sort: Do a new sort, by the SortValue of each card. This should get the former order of the cards back.
> If you do this, you can obviously re-assign the card-values of SortValue at any time, hence you can restore any arbitrary card-order you want with a fresh "sort by SortValue of each card".
> 
> "Bewitched" + "Charlie's Angels" - Charlie = "At Arm's Length" Read the webcomic at [ http://www.atarmslength.net ]! If you like "At Arm's Length", support it at [ http://www.patreon.com/DarkwingDude ].
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


More information about the use-livecode mailing list