Community
cancel
Showing results for 
Search instead for 
Did you mean: 
reeba
Beginner
99 Views

how to use 2d array in parallel sort?

can anyone tell me how to use a 2d array in parallel sort.
for array its - parallel_sort(a, a+n);
i couldnt figure out for 2d array.

Thanks in advance.
0 Kudos
5 Replies
Alexey_K_Intel3
Employee
99 Views

The first question to ask is: what is a sorted 2d array for you? To put it differently, how would you sort a 2d array with std::sort, or even in a hand-written routine?
jimdempseyatthecove
Black Belt
99 Views

>>The first question to ask is: what is a sorted 2d array for you?

right

do you want to sort the "rows" based on values(keys) in one or more columns?
do you want to sort the "columns" based on values(keys) in one or more rows?
do you want each row to have its columns sorted?
do you want each column to have itsrows sorted?
do you want the entire 2d array sorted as calender dates?
(i.e. as if all rows were concatinated in order then having columns sorted, then uncatinated).

These are but 5 differentorders forsorting a 2D array.
(there areother sort orders too)

Jim Dempsey
jimdempseyatthecove
Black Belt
99 Views

Also,

Assume your 2D array is dimension x and where m and n are very large.
Assume youwant to order the rows based on the values contained within one column.

In this case it may be most efficient to produce a 1D vector of indexes to the rows.
This does not require copying/moving the row data. Assume this sorted vector is v
access (after sort) is x[ v ]

This also has a benefit in that multiple views (sorts) of the data can be made or used concurrently.

Jim Dempsey
reeba
Beginner
99 Views

hi,
i would like to know about sorting a 2d array or a vector of vector.

ex; 1 4 13
2 31 33
3 7 21
2 1 3

i would like to get the result as

1 4 13
2 1 3
2 31 33
3 7 21

Thanks in advance.
RafSchietekat
Black Belt
99 Views

Do a one-dimensional sort of row indices with a row comparison predicate and use that as a lookup table to construct the new array.
Reply