- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
for array its - parallel_sort(a, a+n);
i couldnt figure out for 2d array.
Thanks in advance.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Assume your 2D array is dimension x
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page