Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-27-2002, 06:05 AM   PM User | #1
isleshocky77
New Coder

 
Join Date: Jul 2002
Location: New York
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
isleshocky77 is an unknown quantity at this point
Array Sort

If I have an array that looks like this:

Code:
pid[0]="Mike Smith"
pid[1]="Joe Blow"
pid[2]="Brian Slutsky"
How can I sort it by name?
__________________
-Stephen
isleshocky77 is offline   Reply With Quote
Old 07-27-2002, 06:45 AM   PM User | #2
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
As much as I hate the site... its what google found first:

http://www.planet-source-code.com/vb...txtCodeId=6482

And it should do what you want.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 07-27-2002, 04:11 PM   PM User | #3
RadarBob
Regular Coder

 
Join Date: Jun 2002
Location: Round Rock, Texas
Posts: 443
Thanks: 0
Thanked 0 Times in 0 Posts
RadarBob is an unknown quantity at this point
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.

Last edited by RadarBob; 07-31-2002 at 02:39 PM..
RadarBob is offline   Reply With Quote
Old 07-31-2002, 12:22 AM   PM User | #4
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
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)
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)
whammy is offline   Reply With Quote
Old 07-31-2002, 07:36 AM   PM User | #5
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
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.
raf is offline   Reply With Quote
Old 07-31-2002, 02:43 PM   PM User | #6
RadarBob
Regular Coder

 
Join Date: Jun 2002
Location: Round Rock, Texas
Posts: 443
Thanks: 0
Thanked 0 Times in 0 Posts
RadarBob is an unknown quantity at this point
I totally agree with raf. And if you're sorting on an indexed field, sorting should be particularly fast in SQL
RadarBob is offline   Reply With Quote
Old 08-01-2002, 04:49 AM   PM User | #7
isleshocky77
New Coder

 
Join Date: Jul 2002
Location: New York
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
isleshocky77 is an unknown quantity at this point
Thanks... for some reason it completely slipped my mind to use the ORDER BY statement while reading them into the array. Thanks.
__________________
-Stephen
isleshocky77 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:59 AM.


Advertisement
Log in to turn off these ads.