Tag Archives: sorting

Alphanumeric/natural sorting in C# using IComparer

These snippets illustrate the natural sorting order. Suppose you’re using numbers within your file names. For example: file1.png file2.png … file10.png file11.png file12.png You’d expect to see them in the above order. However,  they are (by default) sorted as follows. file1.png file10.png file11.png file12.png file2.png …

Posted in C# | Also tagged , , , , , , , | Leave a comment

(Java) Quicksort in Java, with Enforced Suckitude

It’s no fun implementing QuickSort unless you can force it out of its blister-fast, O(n log n) speed and humiliate it with its worst-case, O(n^2) runtime. So that’s what I set out to do. My naive partition simply pivots around the low item, but my randomized partition defeats the sucky inputs by choosing a random [...]

Posted in Java | Also tagged , , , , , | Leave a comment

(JavaScript) bubble sort

The bubble sort algorithm implemented in JavaScript

Posted in JavaScript | Also tagged , , , , | Leave a comment

Bubble sort algorithm in C

Bubble sort is a basic sorting algorithm where the elements rise to the top of the list. The picture below illustrates the algorithm.

Posted in C | Also tagged , , , , , , , | 2 Comments

Quicksort algorithm in C#

Quicksort is a divide and conquer sorting algorithm. This example uses the quicksort algorithm to sort an array of string elements.

Posted in C# | Also tagged , , , , , , | 13 Comments