title: Checking an array for descending order
body: <p>I am writing code to check if my array is in ascending or descending order. If the boolean 'ascending' is true, then I check if it is ascending. If it is false, then I check for descending. I need help checking whether the array is descending or not... I have the code to check ascending which is written below:  </p>
  
  <pre><code>protected boolean isSorted(boolean ascending) {
      boolean result = false; 
  
      if (ascending) { 
          for (int i=0;i&lt;data.length-1;i++) {
              if(data[i] &lt; data[i+1]) {
                  result = true;
              } else if(data[i] &gt; data[i+1]) {
                  result = false;
              }
          }
      } else {
          //code to check for descending order
      }
  }
  </code></pre>