title: double data type is not sorting properly in priority queue in java
body: <p>I am using priority queue to sort the list of student on basis of cgpa which is a double value. If I am making it as integer than it is working fine or if I add a field name as string and sort on basis of string then also it works fine.</p>
  
  <pre><code>    public class MainClass {
  
  
      public static void main(String[] args) {
  
      // comparator class to sort the student on basis of cgpa.
          Comparator&lt;Student&gt; studentComparator = new Comparator&lt;Student&gt;() {
              @Override
              public int compare(Student s1, Student s2) {
                  if (s1.getCgpa() &lt; s2.getCgpa())
                      return 1;
                  else if (s1.getCgpa() &gt; s2.getCgpa())
                      return -1;
                  else
                      return 0;
              }
          };
  
          Scanner in = new Scanner(System.in);
          int totalEvents = 8;
          PriorityQueue&lt;Student&gt; studentList = new PriorityQueue&lt;&gt;(totalEvents, studentComparator);
         // adding value in to priority queue by taking input from user in cmd
          while(totalEvents&gt;0) {
              double cgpa = in.nextDouble();
              Student student = new Student(cgpa);
              studentList.add(student);
              totalEvents--;
          }
  
          for (Student s : studentList) {
              System.out.println(s.getCgpa());
          }
      }
      }
  </code></pre>
  
  <p>Here is my model class.</p>
  
  <pre><code>    class Student {
  
      private double cgpa;
  
      public Student(double cgpa) {
          super();
          this.cgpa = cgpa;
      }
  
      public double getCgpa() {
          return cgpa;
      }
  
   }
  </code></pre>
  
  <p>Here is my input </p>
  
  <pre><code>3.75
  3.8
  3.7
  3.85
  3.9
  3.6
  3.95
  3.95
  </code></pre>
  
  <p>and here is the output </p>
  
  <pre><code>3.95
  3.95
  3.9
  3.85
  3.8
  3.6
  3.7
  3.75
  </code></pre>
  
  <p>I tried strictfp key word and tried to use Double wrapper class but still same issue.</p>