Is there any equalent for PHP’s usort function in Java? Some library or anything. Thanks.
I guess it could be programmable through some iterfaces, so if you know about something i’d be glad.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
java.util.Arrays.sort(T[] a, Comparator<? super T> c).You’d have to implement the Comparator, which would be equivalent to implementing the function you pass to PHP’s
usort.A silly example of an implementation of the comparator (for Strings):