944,055 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 7276
  • ASP RSS
Jan 24th, 2007
0

Sort multidimensional array on more than one column?

Expand Post »
I'm working in VBScript and want to sort a multidimensional array on two of the columns in it. I've got a function (based on TONS of examples around the Net) that is sorting on one column, but I can't seem to get how to then do a second column. I'm not seeing a lot when searching, either. Is there a known algorithm or something for doing a sort on multiple columns? Someone must have done this before!!

Alternatively, how might I go about taking a request.forms collection, putting that into a two dimensional array (forms name, forms name value) and then in turn splitting the name and putting that into an array? Ehh, that's a bit confusing....here's what I'm trying to do:

I'm building a form dynamically, and building the input names from dynamic data. My forms collection then looks like this - I have a number of name,value pairs like this:

IDNum_CODE_fieldname, value

Ultimately, I want to do something like "update tablename set fieldname=value where idkey=IDNum and codetype=CODE" So I want to parse/split the forms name shown above. Since I'll have common IDNum and CODEs, I want to group them by sorting.

Hope this is a little clearer, and thanks for any info!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
edmicman is offline Offline
33 posts
since Oct 2005
Jan 30th, 2007
0

Re: Sort multidimensional array on more than one column?

here's something that might get you on the right track

try sorting by secondary field first then sort again by primary
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jan 30th, 2007
0

Re: Sort multidimensional array on more than one column?

Thanks for the help! I think I tried that, and all it did was first sort by the second column, and then sort by the first column, independent of what had already been sorted. I think it was the function I was using. Anyway, I gave up on that, and did something else. I ended up just sending over my "value" as IDNum_CODE_fieldname_value, and then sorting that. Sorting a single dimension array is easy, and then I just parsed it out once it was sorted that way. Sometimes the quick and dirty way is right under my nose Thanks again!
Reputation Points: 10
Solved Threads: 0
Light Poster
edmicman is offline Offline
33 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Strange behavior with Date() function
Next Thread in ASP Forum Timeline: Where can I get a Library of std ASP functions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC