Skip to content

Instantly share code, notes, and snippets.

@zkat
Last active December 25, 2015 22:19
Show Gist options
  • Select an option

  • Save zkat/7049182 to your computer and use it in GitHub Desktop.

Select an option

Save zkat/7049182 to your computer and use it in GitHub Desktop.
// Inspired by https://twitter.com/nelhage/status/391265023357513728
function timeoutSort(array) {
var deferred = $.Deferred(),
res = [];
array.forEach(function(x) {
setTimeout(function() {
if (res.push(x) == array.length) {
deferred.resolve(res);
};
}, x + 15);
});
return deferred.promise();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment