-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8u212
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
I have List of Integer when I try to sort it with Stream (by using sorted() method) and collect the result in Set , it returns the incorrect sorted values in set.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Integer List
like List<Integer> list = Arrays.asList(3,4,1,7,9,10,6,8,12,33,22);
and then sort this list using stream
Set<Integer> setSort = list.stream().sorted().collect(Collectors.toSet());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1, 3, 4, 6, 7, 8, 9, 10, 12, 22, 33
ACTUAL -
1, 33, 3, 4, 6, 22, 7, 8, 9, 10, 12
---------- BEGIN SOURCE ----------
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class StreamInJava8 {
public static void main(String[] args) {
List<Integer> list = Arrays.asList(3,4,1,7,9,10,6,8,12,33,22);
Set<Integer> setSort = list.stream().sorted().collect(Collectors.toSet());
System.out.println(setSort);
}
}
---------- END SOURCE ----------
FREQUENCY : always
I have List of Integer when I try to sort it with Stream (by using sorted() method) and collect the result in Set , it returns the incorrect sorted values in set.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Integer List
like List<Integer> list = Arrays.asList(3,4,1,7,9,10,6,8,12,33,22);
and then sort this list using stream
Set<Integer> setSort = list.stream().sorted().collect(Collectors.toSet());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1, 3, 4, 6, 7, 8, 9, 10, 12, 22, 33
ACTUAL -
1, 33, 3, 4, 6, 22, 7, 8, 9, 10, 12
---------- BEGIN SOURCE ----------
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class StreamInJava8 {
public static void main(String[] args) {
List<Integer> list = Arrays.asList(3,4,1,7,9,10,6,8,12,33,22);
Set<Integer> setSort = list.stream().sorted().collect(Collectors.toSet());
System.out.println(setSort);
}
}
---------- END SOURCE ----------
FREQUENCY : always