public static void main(String[] args) {
String[] errorStr = new String[] {
"Line No: " + " " + 1,
"Line No: " + " " + 11,
"Line No: " + " " + 10,
"Line No: " + " " + 2,
"Line No: " + " " + 3
};
Arrays.sort(errorStr);
for(Object obj : errorStr){
System.out.println(obj);
}
}
Can someone point why the sorting is not working here?
expected is,
Line No: 1
Line No: 2
Line No: 3
Line No: 10
Line No: 11
Actual is,
Line No: 1
Line No: 11
Line No: 10
Line No: 2
Line No: 3