Original: Share a very useful Java code, you can sort the comma-separated numbers in a large-to-small way to return
Source code: Http://www.zuidaima.com/share/1550463693032448.htm
For web development, the sorting of multiple IDs is very practical and there is a need for cattle people to download.
Package Com.zuidaima.math;import java.util.arrays;/*** @author Www.zuidaima.com**/public class Sortidstring {public static void Main (string[] args) {String user_ids = "1,3,2,299,33,2"; string[] _ids = User_ids.split (","); System.out.println ("before sort:" + arrays.tostring (_ids). ReplaceAll ("\\[|\\]", "")); for (int i = 0; i < _ids.length; i++) {int largest = i;for (int j = i; J < _ids.length; J + +) {if (Integer.parseint (_ids[j]) > Integer.parseint (_ids[l Argest]) largest = j;} int temp;temp = Integer.parseint (_ids[i]); _ids[i] = _ids[largest];_ids[largest] = temp + "";} System.out.println ("After sorting:" + arrays.tostring (_ids). ReplaceAll ("\\[|\\]", ""));}}
Share a useful Java code that returns a comma-separated number to be sorted from a large to a small way