I am trying to understand the sorting behavior of Collections.sort() when a mixture of numbers and letters are present. From conducting research I understand that numbers sort before letters and string sort alphabetically. However, this example is still a bit confusing to me.Collections.sorts ascending. If numbers are sorted first, why would the result not be [8, 30, 3A, FF]?
In this example below the result is [30, 3A, 8, FF]
List<String> hex = Arrays.asList("30", "8", "3A", "FF");
Collections.sort(hex);
System.out.println(hex);
But in this example the result is [30, 40, 50, 60]
List<String> nums = Arrays.asList ("50", "30", "60", "40");
Collections.sort(nums);
System.out.println(nums);