title: How to do selection sorting
body: <p>I have the following data that needs to be sorted using selection sort. We have itemName, category, quantity and price as instance variables.</p>
  
  <pre><code>“Blouse” “W” 21 17.95
  “Blouse” “C” 35 17.95
  “Shirt”  “M” 13 21.95
  “Pants”  “W” 22 67.95
  “Pants”  “M” 22 62.95
  “Pants”  “C” 26 21.95
  “Coat”   “C” 20 21.95
  “Coat”   “M” 10 62.95
  </code></pre>
  
  <p>Here is my code for selection sort but my output isn't coming out right. When it is supposed to display in ascending order it displays in descending order. what should I do? is my problem in my compare to method or on the code below?</p>
  
  <pre><code>int min;
  Comparable temp;
  for(int index = 0; index&lt; list.length-1; index++)
  {
      min=index;
      for(int scan= index+1; scan&lt;list.length; scan++)
      {
          if(list[min].compareTo(list[scan])&lt;0)
              min = scan;
          temp= list[min];
          list[min] = list[index];
          list[index]= temp;
  </code></pre>