This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swift3 adaption of https://gist.github.com/kazk/5c660d071642193f5301 by https://github.com/kazk | |
// An implementation of [Smoothsort] algorithm invented by Edsger Dijkstra, | |
// which I didn't get until reading [Smoothsort Demystified] by Keith Schwarz. | |
// | |
// Some optimizations like the chained swaps and corner case elimination were | |
// derived from [smoothsort.c] by Martin Knoblauch Revuelta. | |
func smoothsort<T : Comparable>( a: inout [T]) { | |
smoothsort(&a) { $0 < $1 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |