> I have a strange situation. I have to sort a list twice. First by a
> number, descending, then by text ascending.
>
> I know sounds strange but here is an example.
>
> Original list (example only real info stripped out):
> 2-CCC|2-AAA|2-DDD|5-ZZZ
>
> First it has to be sorted by the number, so: 5-ZZZ|2-CCC|2-AAA|2-DDD
>
> Then by the text making the final string: 5-ZZZ|2-AAA|2-CCC|2-DDD
>
> Any ideas?  Using listSort(myVar, "textnocase", "asc", "|")  sorts it
> ascending by the number then the text.

Here's my five-minute, untested, unimplemented solution:

1. Create a new structure.
2. Loop over your original list.
3. Within the loop, examine the first character of each item.
4. Use that to place the item within an array of items within the
structure. Presumably, for example, if you have nine digits, you'd end
up with nine keys within that structure, each of which would point to
an array of all items whose first character matched that key's name.
5. Now, loop over the structure. You can start your loop from the top
and work down.
6. For each key, sort the array items based on the characters after the dash.
7. Loop over the array, and display the items.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more informatio

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:327815
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to