Click to See Complete Forum and Search --> : sort two dimensional arrays


ms26
November 5th, 2002, 04:15 AM
can you please help me with a code for the fastest algorithm? My array size is [640][480]

galathaea
November 5th, 2002, 06:44 AM
Sorting is an inherently one-dimensional procedure. If you want to "sort" an 2-d struct, you have to decompose it into a linear structure.

Some common ways of decomposition are:
Array[0][0], Array[0][1], Array[0][2], ... Array[0][479], Array[1][0], etc.
or
Array[0][0], Array[1][0], Array[2][0], ... Array[639][0], Array[0][1], etc.
or expanding by diagonals
Array[0][0], Array[0][1], Array[1][0], Array[0][2], Array[1][1], etc...

There are many other ways. Do you mean you want to sort as it is linearly arranged in memory?

galathaea
November 5th, 2002, 06:47 AM
Are you asking to sort a collection of arrays? Then I would need to know what form of > or < you intend to invoke. Which map from an array to a real do you intend? Its not a square matrix, so some standard mathematical forms are ruled out. Dictionary ordering?