title: Find the N'th highest number in unsorted array
body: <p>Today in a interview, I was told to write a program which will output the nth highest number in the unsorted array,</p>
  
  <p>I solved this using javascript, the program is as follows,</p>
  
  <pre><code>var fn50 = function(){
      var reverseSort = function(myArray,highest){
          var x = 0,
              y = 0,
              z = 0,
              temp = 0,
              totalNum = myArray.length, // total numbers in array
              flag = false, // is the numbers sorted in reverse while iteration
              isAchieved = false; // whether we achieved the nth highest
  
          while(x &lt; totalNum){
              y = x + 1; // start comparing 'yth' number which is next to 'xth' number.
  
              if(y &lt; totalNum){
                  // start comparing 'xth' with the next number, and if 'xth' number less than its next position number, just swipe them
                  for(z = y; z &lt; totalNum; z++){
  
                      if(myArray[x] &lt; myArray[z]){
                          temp = myArray[z];
                          myArray[z] = myArray[x];
                          myArray[x] = temp;
                          flag = true; // if number swiping done ?
                      }else{
                          continue;
                      }   
                  }                   
              }
  
              if(flag){
                  flag = false;
              }else{
                  x++; // x holds the max number in series, now move to next position to find next highest number 
                  if(x &gt; highest){ // if x is what the desired max number which we want flag it and break the loop to escape further iteration.
                      isAchieved = true;
                  }   
              }
              if(isAchieved){
                  break;
              }
          }
  
          print(myArray[(highest - 1)]);  
      };
  
      reverseSort([12,56,78,34,11,100,95],4); // passing the unsorted array of number's, and finding the 4th highest number
  };
  
  fn50();
  </code></pre>
  
  <p>I got the desired output i.e the answer is 56 from the above array which is the 4th highest number.</p>
  
  <p>But the interviewer told for a better solution.</p>
  
  <p>Can you tell me or give me a hint, how can there be a better solution.
  Some data structure technique ?</p>