sorting-algo-ts
Version:
Sort multiple types of data structures using Bubble Sort.
43 lines (42 loc) • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sorterStart = void 0;
//importing utils
var Radio = require('prompt-radio');
var usePrompt = require('prompt-sync')();
//importing classes
var NumbersCollection_1 = require("./structures/NumbersCollection");
var CharactersCollection_1 = require("./structures/CharactersCollection");
var LinkedList_1 = require("./structures/LinkedList");
var SorterStart = /** @class */ (function () {
function SorterStart() {
this.numbersCollection = new NumbersCollection_1.NumbersCollection();
this.linkedList = new LinkedList_1.LinkedList();
this.characters = new CharactersCollection_1.CharactersCollection();
this.radioPrompt = new Radio({
name: 'dataStructures',
message: 'What data structure would you like to sort?',
choices: ['Array of Numbers', 'Linked List', 'String'],
});
}
SorterStart.prototype.startSorting = function () {
var _this = this;
this.radioPrompt.ask(function (answer) {
if (answer === 'Array of Numbers') {
var len = usePrompt('Enter the length of the array: ');
_this.numbersCollection.sortUserInput(len);
}
else if (answer === 'String') {
var characters = usePrompt('Enter a string of characters: ');
_this.characters.sortUserInput(characters);
}
else {
var len = usePrompt('Enter the number of items to append to the list: ');
_this.linkedList.sortUserInput(len);
}
});
};
return SorterStart;
}());
//start sorting
exports.sorterStart = new SorterStart();