Sort muli-array or better datamodel?

Hi all.Still looking for some “assistance”…

Basically, an agent will loop an all documents in a view, get me some 10 fields data from other documents in different views.

So I get a section of data

position + country + location + name + …

The first solution is to use different views sorted as “main view” to get documents from. But I am looking for a generic LS-way to do a sort.

I do only want to sort one column but of course re-arrange the other fields accordingly.

So either a sort on

arr[1] = “1, Norway, Oslo, Bo, Cat, red car, dog”

arr[2] = “5, Norway, Trondhem, Stein, Dog, blue car, fish”

arr[3] = “2, Denmark, Copenhagen, Vide, Ferret, MC, ostrich”

Ideally I would like to sort on “col 1” OR sort on “col 2” OR …

I guess that is a bit to complex?

Subject: sort muli-array or better datamodel??

Tony,

I guess you should use List data type for each key ( position,country,location and name ) . So there will be five list. Once data is stored in List , sort your list by list tag so your list will be sorted by name. Once done loop through list and build your key.

Rishi

Subject: sort muli-array or better datamodel??

Your best option is to use either a Type or a Class (I’d use a Class in this instance) with one member for each of the columns you want to use, and a separate member for a comparator value. You can easily run through the entire array once to set the comparator value to equal whichever of the other “columns” you want to use for sorting. Doing that in one pass before the sort should save considerable time compared to doing the “which value do I use” routine multiple times on any given array member during the sort itself. Then it’s simply a matter of doing your favorite sort routine on the array of objects using the comparator member value.