//對字符串數字排序 Stream.of("123", "321", "132","312").sorted(Comparator.comparingInt(Integer::parseInt)) // 對Object屬性排序 Stream.of( new Exception("13"), new Exception("1"), new Exception("21"), new Exception("3") ).sorted(Comparator.comparing(Exception::getMessage, Comparator.comparingInt(Integer::parseInt)));