...

View Full Version : Array Sort



isleshocky77
07-27-2002, 06:05 AM
If I have an array that looks like this:



pid[0]="Mike Smith"
pid[1]="Joe Blow"
pid[2]="Brian Slutsky"


How can I sort it by name?

oracleguy
07-27-2002, 06:45 AM
As much as I hate the site... its what google found first:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6482

And it should do what you want.

RadarBob
07-27-2002, 04:11 PM
Hint: My experience is that upper case letters get sorted ahead of lower case, thus "Xylophone" will be in front of "apple." I've gotten around this by using the toUpperCase() function in Javascript.

whammy
07-31-2002, 12:22 AM
Haven't run into that problem in ASP, but if it's an issue (which I don't have time to test at the moment, but if I remember correctly, it's not an issue), you can do the same thing in ASP... heck it's a good thing to know anyway:

myString = UCase(myString)

or

myString = LCase(myString)

raf
07-31-2002, 07:36 AM
Another hint : use ASP for what it was ment, and SQL and database for what they were ment.

in 99.9% of the cases, you can sort your data before an array whas created with something like
"select * from table where state=1 order by name desc"

like this you can choose the variable and the order (ascending or descending) If you pull it out of a DB, go SQL.

RadarBob
07-31-2002, 02:43 PM
I totally agree with raf. And if you're sorting on an indexed field, sorting should be particularly fast in SQL

isleshocky77
08-01-2002, 04:49 AM
Thanks... for some reason it completely slipped my mind to use the ORDER BY statement while reading them into the array. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum