natorder icon indicating copy to clipboard operation
natorder copied to clipboard

Zero is not sorted properly

Open krasa opened this issue 2 years ago • 0 comments

It should not skip the zero if there is no other digit.

Unsorted: [9, 0, 1, a[9], a[0], a[00], a[1]]
Sorted: [0, 1, 9, a[1], a[9], a[0], a[00]]
Should be: [0, 1, 9, a[0], a[00], a[1], a[9]]
static void bug() {
	List<String> unSorted = Arrays.asList(
			"9",
			"0",
			"1",
			"a[9]",
			"a[0]",
			"a[00]",
			"a[1]"
	);

	System.out.println("Unsorted: " + unSorted);

	unSorted.sort(new NaturalOrderComparator());

	System.out.println("Sorted: " + unSorted);
}

krasa avatar Nov 25 '22 10:11 krasa