To read the article online, visit http://www.4GuysFromRolla.com/webtech/012799-1.shtml

 WebWeekly: Sorting Arrays * This WebWeekly presents a Quicksort algorithm you can use to quickly sort your arrays in ASP. For the past six months or so, I've been reading and participating in a number of ASP ListServ groups. One question which arises often is how to sort an array efficiently. There are *many* sorting algorithms available, each having its own advantages and disadvantages. The simplest sort, a bubble sort, is good for small arrays, especially ones that are nearly sorted already. However, as the set of data to be sorted starts to grow, a bubble sort becomes quite inefficient. The sort that is regarded as the best sort for large arrays that are NOT nearly sorted is Quicksort. Quicksort uses a divide and conquer approach, dividing the total array in half, then recursively dividing each half info halves, and those halves into halves and so on and so on. Eventually, it just has two values, and can swap them if needed. While this is not exactly how a Quicksort works, it is a general description. What to remember is that a Quicksort uses a divide and conquer approach utilizing recursion. This leads to a big O of N log N. I implemented this Quicksort algorithm using JavaScript. Since you can use JScript as a server-side language with ASP, its cut & paste time. You can also, as this code shows, use your Quicksort algorithm with client-side scripting as well. If you would like to see this algorithm coded in VBScript, let me know, and if there is enough interest, I will go ahead and provide a link to a VBScript implementation in the next WebWeekly. An implementation of Quicksort in VBScript using one dimensional arrays can be at this URL. A VBScript implementation using two dimensional arrays can be found at this URL. `````` `````` If you have any questions regarding how or why Quicksort works, and why it is efficient, simply email me (mitchell@4guysfromrolla.com) with your question(s). Also, if a discussion on other sorts (such as bubble sort, selection sort, heap sort) is called for, please simply ask. Happy Programming!

 Article Information Article Title: 4GuysFromRolla.com - WebWeekly: Sorting Arrays Article Author: Scott Mitchell Published Date: Wednesday, January 27, 1999 Article URL: http://www.4GuysFromRolla.com/webtech/012799-1.shtml