ID:168316
 
I was wondering, is there anyway to check if items in a list are in a certain order?
There certianly is. My big utility library (p_utility) has procedures that determine whether a list of numbers is in ascending order or descending order, and if there's some other order you want to check for it's certianly possible.
In response to PirateHead
Does your big utility library include ABC order?!!?!
In response to CaptFalcon33035
In fact, I believe it does. Unless I'm mistaken, I added alphabetical order checking into the latest release. Enjoy!
In response to PirateHead
How'd you do it? A list of characters, using Find() and creating a temporary list for each element within a list, then compare lists?!!? Lol, that was my idea of doing it.
In response to CaptFalcon33035
From the library:

proc
compare_alphabet(string1 as text, string2 as text) //case-sensitive
var/shorter
if(length(string1)<length(string2)) shorter=string1
else shorter=string2
for(var/i=1,i<=length(shorter),++i)
var
val1 = text2ascii(lowertext(copytext(string1,i,i+1)))
val2 = text2ascii(lowertext(copytext(string2,i,i+1)))
if(val1<val2) return -1
else if(val1>val2) return 1
return 0
compare_Alphabet(string1 as text, string2 as text) //case-sensitive
var/shorter
if(length(string1)<length(string2)) shorter=string1
else shorter=string2
for(var/i=1,i<=length(shorter),++i)
var
val1 = text2ascii(copytext(string1,i,i+1))
val2 = text2ascii(copytext(string2,i,i+1))
if(val1<val2) return -1
else if(val1>val2) return 1
return 0
sorted_alphabetically(list/l)
if(l.len<2) return 1
for(var/i=1,i<l.len,++i) if(compare_alphabet(l[i],l[i+1])==1) return 0
return 1
sorted_Alphabetically(list/l) //case-sensitive
if(l.len<2) return 1
for(var/i=1,i<l.len,++i) if(compare_Alphabet(l[i],l[i+1])==1) return 0
return 1


For more, go ahead and download the (free) library.
In response to PirateHead
Why not just use sorttext and sortText? Or is this one of those libraries whose sole purpose is to do extra work when there are built-in procs that do the same thing? :p
In response to tenkuu
Ooh! I didn't know those built-ins existed! Thanks, Tenkuu.
In response to PirateHead
Eh, that didn't look like it'd work too well, though. It looks as though it checks to see only if the first letter is ascending or descending. Then again, I'm not too good at text procs, or even knowing what they do or how they function.
In response to tenkuu
I was not aware of these procs. Dammit, and I had such a long proc for alphabetically sorting lists.
In response to CaptFalcon33035
Thanks for the help.