Here the list.
var/list/L=list("Z","z","d","j","A","Z")
I want it to come out like this.
L=list("A","d","j","Z","Z","z")
Some help would be nice :).
- Darky
ID:271378
![]() Jun 6 2007, 1:52 pm (Edited on Jun 7 2007, 7:08 am)
|
|
Does anyone know how I would be able to sort a list into alphabetical order? Ive been stumped on this a bit.
Here the list. var/list/L=list("Z","z","d","j","A","Z") I want it to come out like this. L=list("A","d","j","Z","Z","z") Some help would be nice :). - Darky |
Jp wrote:
I believe > and < (and all their variants) work on strings, too. Yep they do, but they are equivalent to sortText(), which wouldn't do what Dark Emrald wants, since his is case insensitive. |
Xx Dark Wizard xX wrote:
You may want to lowertext when comparing since < and > compare in ascii order, not alphabetical. Unknown Person wrote: DM has a nifty sorttext() function. It doesn't do any actual sorting, but it can tell you if a letter is before or after alphabetically, since in your case you want a case insensitive sort in letters. You can use this proc inside of your sorting algorithm. Look up the proc, and you should be able to modify the sort to sort for text. |
A bubble sort for numbers would look like this:
For more information of how these sorts work, there are a massive amount of resources on these topics online (since sorts refer to all programming languages). There are also some pretty useful libraries on BYOND that can do this for you.
DM has a nifty sorttext() function. It doesn't do any actual sorting, but it can tell you if a letter is before or after alphabetically, since in your case you want a case insensitive sort in letters. You can use this proc inside of your sorting algorithm. Look up the proc, and you should be able to modify the sort to sort for text.