https://leetcode.com/problems/sorting-the-sentence/


Runtime: 75 ms, faster than 66.04% of TypeScript online submissions for Sorting the Sentence.

Memory Usage: 43.5 MB, less than 30.19% of TypeScript online submissions for Sorting the Sentence.


```typescript
function sortSentence(s: string): string {
    //9:07
    const wordMap = new Map();

    for (const word of s.split(" ")) {
        wordMap.set(Number(word.charAt(word.length-1)), word.substring(0, word.length-1))
    }
    
    let keys = [...wordMap.keys()].sort(function (a, b) {  return a - b;  });
    
    return keys.map((key) => wordMap.get(key)).join(" ")
    //9:17
};
```
