Sort multidimensional array on more than one column?

Reply

Join Date: Oct 2005
Posts: 33
Reputation: edmicman is an unknown quantity at this point 
Solved Threads: 0
edmicman's Avatar
edmicman edmicman is offline Offline
Light Poster

Sort multidimensional array on more than one column?

 
0
  #1
Jan 24th, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Sort multidimensional array on more than one column?

 
0
  #2
Jan 30th, 2007
here's something that might get you on the right track

try sorting by secondary field first then sort again by primary
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 33
Reputation: edmicman is an unknown quantity at this point 
Solved Threads: 0
edmicman's Avatar
edmicman edmicman is offline Offline
Light Poster

Re: Sort multidimensional array on more than one column?

 
0
  #3
Jan 30th, 2007
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!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC