Introduction
             Welcome. Regardless of how you managed to get here, you’re probably wondering what Ninja Sort is. For this reason, I have prepared the following list of questions and answers.

Questions and Answers
       What is Ninja Sort?
      Ninja Sort is a sorting algorithm (a specific way to sort numbers) designed to kick the ass out of every other sorting algorithm.

Does Ninja Sort kick the ass out of every other sorting algorithm?
      No.

What gives?
      Ninja Sort is still under development. You see, there are dozens of sorting algorithms in use today. My goal is to develop a sorting algorithm that can out perform all others. Achieving this goal would mean computer science majors would no longer be forced to learn Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Heap Sort, Quick Sort, Radix Sort, Bucket Sort, etc. As a result, computer science majors would be given a chance to regain their sanity. Upon completion of Ninja Sort, I will expect thank you notes.

How long before Ninja Sort is complete?
      There are essentially two parts in creating an algorithm, coming up with a name and actually creating the algorithm. I’ve gotten the hard part over with, now I just need to create an algorithm.

So you don’t even have an algorithm?
      Oh I have an algorithm, it just sucks. Below is the current source code for Ninja Sort. I’ll update it as it improves. Currently it’s a little faster than Insertion Sort. Don’t ask me for its time complexity, because I haven’t figured it out.

What's its time complexity?
      Ass.

Source Code
      
public static void ninjaSort(int[] nums, int s, int e){
  int i, j, k, p, t;

  p = s;
  for(i = p + 1; i <= e; i++)
    if(nums[p] <= nums[i] || i == e){
      if(i == e && nums[p] > nums[i])
        i++;
      else if(i == p + 1){
        p++;
        continue;
      }

      if(i != p + 2) ninjaSort(nums, p + 1, i - 1);
      k = p + 1;
      for(j = s; j < p; j++)
        if(nums[j] >= nums[k])
          do{
            t = nums[k];
            while(k > j) nums[k] = nums[--k];
            nums[j++] = t;

            k = ++p + 1;
            if(k == i){
              j = p;
              break;
            }
          }
          while(nums[j] >= nums[k]);

      t = nums[p];
      while(p < i - 1) nums[p] = nums[++p];
      nums[p++] = t;
    }
}
http://www.okthen.com Email: theonion@cox.net