Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a table in vbscript

Status
Not open for further replies.

Albuckj2

Programmer
Jan 7, 2003
68
GB
I have a page that dynamically displays the results from a database following a form query from a user on a previous page. However, I need the results table to be sorted by the user by simply clicking the column headings. This needs to be done on the client side by, I hope, vbscript.

I could construct some way of doing it if I knew of a quick way to sort an array. JavaScript has a sort function for arrays, but vbscript doesn’t.

Any ideas on sorting a table by headings on the client side using vbscript???

 
There is a simple QuickSort in VBScript at
The way it is built it only sorts a range of elements in a one-dimensional array into ascending order.

To:

* Sort stuff from a table based on one column of the table, or

* To do descending sorts as well

... well you'll need to rework the thing a bit. I think it was meant as a way to get started.

I haven't seen too many VBScript sorts out there.

The other option is to create an ADO RecordSet, load the data into it, use the RecordSet's Sort method, put the data back into the table.

Even using the VBScript QuickSort you'd want to copy the data into an array, sort it, and copy it back or else it might look pretty strange to the user and it'll take a while longer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top