Skip to content

Instantly share code, notes, and snippets.

@agilob
Created May 18, 2018 12:21
Show Gist options
  • Save agilob/4b5d6b12d51fb194f2d25540bb4a12ed to your computer and use it in GitHub Desktop.
Save agilob/4b5d6b12d51fb194f2d25540bb4a12ed to your computer and use it in GitHub Desktop.
Sleep sort implementation in Dart
import 'dart:async';
class Input {
var sleepTimes = new List();
}
main(List<String> arguments) async {
var input = new Input();
arguments.forEach((val) { input.sleepTimes.add(num.parse(val)); } );
input.sleepTimes.forEach((time) {
mSleep(time);
});
}
mSleep(int value) async {
runFutures(value);
}
Future runFutures(int value) {
return runLater(value).then((result) {
print(value);
});
}
Future runLater(int value) {
return new Future.delayed(new Duration(seconds: value));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment