bucket sort on cell array of vectors
2 views (last 30 days)
Show older comments
hi guys,
i need your help in solving the following problem:
Given a cell array of vectors, sort them in a bucket sort manner.
Here is an example to ease the question:
thanks in advance.
0 Comments
Accepted Answer
Guillaume
on 2 Dec 2015
Edited: Guillaume
on 2 Dec 2015
c1 = {[1 2] [10 11];[2 3] [10 11];[1 2] [11 12]; [2 3] [11 12]};
c2 = table2cell(sortrows(cell2table(c1)))
Note that you haven't defined in the question how you order vectors. The above uses lexicographical ordering.
It's unfortunate that sortrows on cell array only work with scalar cell (unless the cells are all of type char), hence the conversion to table and back.
0 Comments
More Answers (0)
See Also
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!