Sorting a BigInteger array
5 views (last 30 days)
Show older comments
I need to sort an array but the contents are BigIntegers. When I try use the "sort(A)" function I get the following error:
Error using sort
Unknown command option.
Is it because the array is type BigInteger[] ? And if that's the case, how can I sort it?
0 Comments
Accepted Answer
Jan
on 29 Apr 2022
How dod you create the array? Please post a short example. I seems that you are talking about a Java class, not a Matlab array. Then use a Java method for sorting...
FEX: HPF might be useful. It has implemented an merge sort.
4 Comments
Jan
on 2 May 2022
@Michelle Lear: The link does not uniquely explain, how you have defined your array of BigIntegers. It would be helpful if you post your code instead of letting me guess the details.
I've showed you the code to inster the BigIntegers in a java.util.ArrayList, and this is a valid input for java.util.Collections.sort. If you use the suggested method, you will not get this error message.
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!