Alpha sorting an array? Alpha sorting an array? zero2130 (Programmer) (OP) 2 Feb 01 15:02 How can I do this?I have an array that I want to be sorted alphabetically. Is there an easy way to do this or do you know of/have you written a function that'll do this?Thanks RE: Alpha sorting an array? Guest (visitor) 5 Feb 01 14:42 There are a few traditional algorithms ( not that Al Gore has rhythm ) for performing such a sort, such as the bubble sort, etc. It would probably require slightly less code ( and would be a lot sexier ) to load the data into an XML Document object and then perform a select nodes with a sort applied.Does anybody miss perl hash tables yet?JAC RE: Alpha sorting an array? wrbodine (Programmer) 12 Dec 01 16:42 Does Jac or anyone have an example of loading the data into an XML document? I think the sort part in XML will be easy but I've never yet loaded data from VBScript code into an XML document....Thanx,Ray RE: Alpha sorting an array? dilettante (MIS) 15 Dec 01 00:38 Take a look here: http://www.angelfire.com/mi4/bvo/deliveries.htmlThere is a nice VBScript sort all ready to include using a <script> tag. RE: Alpha sorting an array? Parke (Programmer) 20 Dec 01 16:08 Why not load the array into a disconnected recordset and sort? RE: Alpha sorting an array? wrbodine (Programmer) 20 Dec 01 16:12 We've been wanting to start using XML here, so I thought it would be a good chance to get my feet wet. I'm using a bubble sort for now, but am intrigued by the recordset idea as well, since I've never heard of doing that.... RE: Alpha sorting an array? Parke (Programmer) 21 Dec 01 08:38 Here is an example of using a recordset to sort.option explicitDim myArrayDim rstDim sDim xitemmyArray = Array("Parke Kuntz", "Jane Doe", "Mary Smith", "John Cole", "May Abbot","John Doy", "Mary Scale")' create a recordsetSet rst = createObject("ADODB.Recordset")' create/append the fields to the recordsetrst.Fields.Append "fullname",129,50 'AD_Char = 129 and character length is 50rst.Fields.Append "fname",129,50rst.Fields.Append "lname",129,50' open the recordsetrst.Open' insert the array into the recordsetFor Each xitem in myArray rst.AddNew rst.Fields("fullname") = xitem ' extract the first name from fullname rst.Fields("fname") = Left(rst.Fields("fullname"), Instr(rst.fields("fullname")," ") -1) ' extract the last name from fullname rst.Fields("lname") = Right(rst.Fields("fullname"), (Len(rst.Fields("fullname"))-Instr(rst.Fields("fullname")," "))) rst.MovenextNextrst.moveFirst' choose the field to sort onrst.Sort = "lname"s = "sorted by last name"Do until rst.EOF s = s & vbcrlf & rst.Fields("fullname") rst.MoveNextLoopmsgbox ss = "sorted by first name"rst.MoveFirst' choose the order of the fields you want to sort onrst.Sort = "fname, lname"Do until rst.EOF s = s & vbcrlf & rst.Fields("fullname") rst.MoveNextLoopmsgbox sHope this helps, RE: Alpha sorting an array? jbaywatch (Programmer) 24 Dec 01 00:45 Wow, not to be argumentative or disrespectful to anyone. But isn't both of those methods (XML and RS) a waste of server cycles?I just don't understand why anyone would go to such lengths as to spawn new processes to sort an array in a production environment.I would use the bubbleSort, XML and ADO have their places and IMHO, this isn't it.Fo the XML method I am guessing you would have to actually create 2 instances of The MSXML parser. One for the DOM and one for the XSL transform that will actually perform the sort.Just my 2 cents.-J RE: Alpha sorting an array? Parke (Programmer) 24 Dec 01 09:04 If all that was wanted was a simple sort, I would agree with you. With recordsets, one can sort on different columns by priority simply by filling in .sort = "field1, field2,field3..." This is the second sort. Doing this is more difficult using sorting routines.