posRecordList.stream() .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTransactionNo()+f.getStore()+f.getLineNum()))), ArrayList::new));