Re: simplest way to sort a bi-dimensional array? mat(a,b)...




"ginko" <ginko@xxxxxxxxxxx> wrote in message
news:mn.d3dc7d7750ad496b.77691@xxxxxxxxxxxxxx
i am so glad of all your answers, but...i dont understand ..

anyway i have to give an unniversity exam about fortran and now i am doing
programs to exercising.
we'll have to write a program, and i don't know how it will be.

i only know that the teacher asks for programs like sorting algorithms.

i can sort a mono-dimensional array.
but i don't know how to sort a 2d array!!

maybe i can try to rebuild the array, finding the first max in all the
array and put it into another array => new_mat(1,1)
then i will find the second max and place it to new_mat(1,2) and so on...


what do you suggest me ?



Let's take a simple example :
Suppose you have the following initial matrix; 4 rows 3 columns

row(1) 12 10 7
row(2) 4 8 11
row(3) 9 5 2
row(4) 1 3 6

After the sort what do you expect to see ?

(a) Sorted ascending in both column and row
row(1) 1 2 3
row(2) 4 5 6
row(3) 7 8 9
row(4) 10 11 12

or
(b) data in each row ascending, but row order unchanged
row(1) 7 10 12
row(2) 4 8 11
row(3) 2 5 9
row(4) 1 3 6

or
(c) data in each column ascending, column order unchanged
row(1) 1 3 2
row(2) 4 5 6
row(3) 9 8 7
row(4) 12 10 11

or ...

Now do you see how difficult it is ?
You need to know exactly what you are trying to sort, and why.

Les


.



Relevant Pages

  • Re: "Sorting" assignment
    ... And many others prefer to call partition exchange because "quicksort" ... bin B depending on whether it is greater than, ... If the array is already sorted, this means that you end up ... attempt to sort them. ...
    (comp.programming)
  • Re: A Fast sorting algorithm for almost sorted data
    ... far my compressor has potential but is nowhere near ready. ... It does however make heavy use of sorting. ... which I am currently calling Run sort. ... entire selected run can be added to the sorted output array. ...
    (comp.compression)
  • Re: Formula not working
    ... My data is on sheet 3 in columns a and b. ... but I was thinking Match and Index since the ascending ... range of cells and then do an ascending sort on them and see how Excel sorts ... Note how the last array containing numbers is actually the third argument ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Formula not working
    ... Valko" wrote: ... lookup_vector *must* be sorted ascending. ... range of cells and then do an ascending sort on them and see how ... Note how the last array containing numbers is actually the third ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Formula not working
    ... toppers NOSPAMjohntopley.fsnet.o.uk ... but I was thinking Match and Index since the ascending ... range of cells and then do an ascending sort on them and see how Excel sorts ... Note how the last array containing numbers is actually the third argument ...
    (microsoft.public.excel.worksheet.functions)