All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
ASP,function,will,sort,array,reorder,informat
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,252. lines
 Jobs: 101. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login

NEW! LEARNING CENTER
Special educational offers, white papers, webcasts, podcasts

  NEW! Download Rational Performance Tester V8 (download now)
  NEW! Download Rational Functional Tester V8 (download now)
  NEW! Download Rational Service Tester for SOA Quality V8 (download now)
  NEW! Teleconference: Quality In Action - Using Rational Quality Manager with Functional, Performance and Web Service Testing Products (download now)
  NEW! Introducing IBM Rational AppScan Developer Edition – easing security testing by non-security professionals (download now)

 

 


Latest postings for ASP/ VbScript.
Web Online Examination
By Suhas Manjunath Kashyap on 11/7


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

Multidimensional Array Sort function in VB Script

Print
Email
 
winzip icon
Submitted on: 7/28/2006 3:38:14 PM
By: Eric Repec InetSolution  
Level: Advanced
User Rating: By 4 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 99740 times.
 
author picture
(About the author)
 
     This function will sort an array. It will reorder all the information in each row of the array so that the selected column of the array is sorted. The first row of the array is used to decide what variable types are being used for the sort column. I use this in many of my sites where I have to pull back encrypted data from the database. I decrypt the data with an Active X object inside of the ASP script then place all the data into an array. Once the data is in the array I can sort it and display it to the user. Future enhancements to this function will include the ability to select which column of the array you would like to sort on. This function has been very popular so I am keeping an up to date version of it on our business site. See my profile for the link to InetSolution. Thanks Happy coding Eric Repec

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.

Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:
1)Re-scan downloaded files using your personal virus checker before using it.
2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 1 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
3/21/2001 12:02:54 PMTimothy J. Ward

Could you post a sample of this being used?
(If this comment was disrespectful, please report it.)

 
9/12/2001 2:41:28 PMRachel

Can you please post a sample as to how to use this function..

Thanks.
(If this comment was disrespectful, please report it.)

 
12/10/2001 10:26:05 AMTurbosig

This is awesome... To sort by any other columns, simply pass in another value which represents the column to sort by. Works great. Thanks.
(If this comment was disrespectful, please report it.)

 
11/11/2003 10:21:27 AM

Could you post a sample of this being
used? please!
(If this comment was disrespectful, please report it.)

 
5/27/2004 10:59:24 AM

When I use it it doesn't sort integers properly. It sorts like this:

1
11
2
3
34
4
5
6
65
7
8
9

That's not right is it! :)

Additional variables for DESC or ASC would be cool too. :)

Otherwise it rocks.
(If this comment was disrespectful, please report it.)

 
5/27/2004 1:32:02 PMEric Repec InetSolution

I do have an updated version of this routine if you would like it. The new version take in account of the data type and will fix the problem outlined above.
(If this comment was disrespectful, please report it.)

 
6/21/2004 5:42:51 PM

Hello:
Where we can view the source code for the new version of the sorting Multi-dimension array?
(If this comment was disrespectful, please report it.)

 
7/28/2004 7:49:13 PM

this is excellent!! one question:

in the test loop, what purpose does the following serve?
smallest_value = values(0,j)

it doesn't seem to be used for anything, and then when you loop back through the outer loop, it just gets reassigned.
(If this comment was disrespectful, please report it.)

 
12/10/2004 7:24:37 AM

this is also a great resource for multi-D array's
http://www.aspfree.com/c/a/ASP/How-to-Sort-a-Multi-Dimensional-Array/3/
(If this comment was disrespectful, please report it.)

 
5/18/2006 2:27:55 PMHolzberg

This is a nice function, however if you have the following:
arr(0,0) = "002"
arr(0,1) = "AAA"
it will error on cdbl.
The reason is because only the first value is checked to see what datatype should be used.

Instead, the code should loop through all values and if you have a mix of types then set it to 0 (String) (Hint: once a string or mix is found exit the loop to speed things up)

(If this comment was disrespectful, please report it.)

 
6/25/2006 8:55:50 PMUsing Multidimensional Array Sort function

Can I use this function to sort data with multiple columns in WSH?

It seems to me that this code works with WSH, but I just don't know how to use the function.

I attempted to by doing the following, but it did not work.

Function ArraySort(values(),intSortCol,strDirection)

I have an array with value, and I insert the value like:

Function ArraySort(arrayvalu,3,a) into the first line of the function, but I get an error "Subscript out of range: 'LBound' at the line "min = LBound(values,2)" inside the code.

Could you please let me know why I get the error?

Thanks!


(If this comment was disrespectful, please report it.)

 
2/2/2008 12:53:00 AMErin

Hi there,

Can you please post a sample of how you use this function?

Many thanks!

Erin
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2008 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.