Sorted() in lambda's not working as intended - Java 8 : <p>While learning lambda's, I found sorted method is not working as intended.</p>

<p>The following program is giving  <code>[1, 33, 2, 4, 5, 11]</code> as an output, however I am expecting a sorted output.</p>

<p>Strange thing is when I replace the <code>[33, 2, 1, 4, 5, 11]</code> with <code>[ 3, 1,2, 4, 5]</code> every thing works fine and I got the sorted output as expected.</p>

<pre><code>public class Test {
            public static void main(String[] args) {
            List&lt;Integer&gt; list = Arrays.asList(33, 2, 1, 4, 5, 11);
            Set&lt;Integer&gt; set = list.stream().sorted().collect(Collectors.toSet());
            System.out.println(set);
        }
      }
</code></pre>

<p>Please help me understand this behavior.</p>
