/*
 * 
 */

//================================================================================

bool loopFLAG = true;
byte arrayLength = 8;
byte theArray[8] = {55, 42, 69, 36, 13, 99, 87, 79};

//================================================================================

void setup() {

  Serial.begin(9600);
  Serial.print("Setup is now... ");
  Serial.println("complete!");

} // setup

//================================================================================

void loop() {
if (loopFLAG == true) {

  // PRINT OUT THE ORIGINAL ARRAY
  for (int i = 0; i < arrayLength; i++) {
    Serial.print(theArray[i]);
    Serial.print("  ");
  }
  Serial.println();






  // PUT ARRAY IN ORDER, RISING
  for (int j = (arrayLength - 1); j > 0; j--) {
    for (int i = (arrayLength - 1); i > 0; i--) {
      if (theArray[i] < theArray[i - 1]) {
        byte tempSpot = theArray[i - 1];
        theArray[i - 1] = theArray[i];
        theArray[i] = tempSpot;
      }
    }  // compare element to other elements
  }  // run the for loop as many times as there are elements
  
  
  
  
  // PRINT OUT THE ORDERED ARRAY
  for (int i = 0; i < arrayLength; i++) {
    Serial.print(theArray[i]);
    Serial.print("  ");
  }
  Serial.println();

  // PRINT OUT THE ORDERED ARRAY, BACKWARDS
  for (int i = (arrayLength - 1); i >= 0; i--) {
    Serial.print(theArray[i]);
    Serial.print("  ");
  }
  Serial.println();

  // PRINT OUT THE ORDERED ARRAY, STAIRCASE UP
  for (int i = 0; i < (arrayLength - 1); i++) {
    Serial.print(theArray[i]);
    Serial.print("  ");
    if ((i + 2) < arrayLength) {
      Serial.print(theArray[i + 2]);
      Serial.print("  ");
    }
  }
  Serial.println();

  // PRINT OUT THE ORDERED ARRAY, STAIRCASE DOWN
  for (int i = (arrayLength - 1); i >= 0; i--) {
    Serial.print(theArray[i]);
    Serial.print("  ");
    if ((i - 2) > 0) {
      Serial.print(theArray[i - 2]);
      Serial.print("  ");
    }
  }
  Serial.println();






loopFLAG = false;
Serial.println("The loop has stopped!");
} // loop tag
} // loop

//================================================================================