C sort implementation to compare against swift.