JSFiddle - React, Tailwind, and code Playground

by CommandLineDesign

JavaScript

var Sorter = function(inputString) {
  this.wordsArray = inputString.split(' ');
  this.returnArray = [];
	this.performSort = function(){
		for(var i = 0; i < this.wordsArray.length; i++){
    	var currentNum = Number(this.wordsArray[i].replace(/\D/g, ''));
      this.returnArray[currentNum] = this.wordsArray[i];    
    }
    return this.returnArray.join(' ').slice(1);
  }
}

var mySorter = new Sorter("is2 Thi1s T4est 3a");
console.log(mySorter.performSort() == "Thi1s is2 3a T4est");

//Test.assertEquals(order("is2 Thi1s T4est 3a"), "Thi1s is2 3a T4est")