How to sort an ArrayList with object using stream().sorted()

前端 未结 5 1595

I am having real trouble with using stream and sorted to sort my ArrayList and hope someone can help out. The code uses Croatian words, but I don\'t think that will be a pro

5条回答
  •  孤城傲影
    2021-01-13 09:22

        Object[] sortirano = listaPublikacija.stream().sorted((s1, s2) -> Double.compare(s1.getCijena(), s2.getCijena())).toArray();
    

    this worked, ty for the answer

提交回复
热议问题