From https://bitbucket.org/loyolachicagocs_books/introcs-csharp-examples/src/default/sorting/sorting.cs