Jim, > I've been playing around with the sort function for my > property lists in order to have a sorted list that I > can add properties to at any time in any order and > have it sort it correctly. The problem I'm having is > that when you add numbers like 1, 17 and 129 it only > sorts them up to the 2nd character so 129 comes before > 17 in the list. Also some of these numbers are > followed by a letter such as 15a, 15b, 15c, etc and > these are entered in any order as well. > > Does anyone know how to get around this?
Can you clarify something for me, you said "The problem I'm having is that when you add numbers...", but then you discuss integer values and what appear to be strings (15a), is your list populated with _strings_ or _numbers_, or both? Just because a string looks like a number doesn't make it one, for example, "19" is a string with two characters whereas 19 is the actual integer value, when sorting strings are handled very differently than numbers are and thus "129" will sort _before_ "17", just like "abi" sorts before "ag". In my tests if I use numbers in my list, 17 properly sorts before 129. But if you mix strings and numbers in a list then I believe it sorts them based on how their string representations would look. Therefore: X = ["16",129,17] X.sort() put X -- [129,"16",17] So it sorted the list as if it was ["16","129","17"], in that case there's no real way to sort them otherwise, welcome to sorting of mixed data types. Can you convert all entries to numerical values so you get "proper" sorting based on your expectations? So instead of adding "16b" to your list, add 16.2, then sort the list? X = [129,1,17,15.1,15.3,15.2] ( really 129,1,17,15a,15c,15b ) X.sort() Is that possible? Cheers, Tom Higgins Product Manager - Director Team Macromedia ... [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
