Issue #251
function sort() {
const string =
`
- Favorite WWDC 2017 sessions https://github.com/onmyway133/blog/issues/56
- Favorite WWDC 2018 sessions https://github.com/onmyway133/blog/issues/245
- How to do clustering with Google Maps in iOS https://github.com/onmyway133/blog/issues/191
`
const lines = string
.split('\n')
.filter((line) => { return line.length > 0 })
.map((line) => {
let parts = line.trimEnd().split(' ')
let lastPart = parts[parts.length-1]
let number = lastPart.replace('https://github.com/onmyway133/blog/issues/', '')
return {
line,
number: parseInt(number)
}
})
lines.sort((a, b) => {
return (a.number < b.number) ? -1 : 1
})
const sortedString = lines
.map((tuple) => {
return tuple.line
})
.join('\n')
console.log(sortedString)
}
Then node index.js