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!

Recommended Answers

All 2 Replies

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

try sorting by secondary field first then sort again by primary

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.