loading...

re: Daily Challenge #253 - Sort Sentences Pseudo-alphabetically VIEW POST

FULL DISCUSSION
 
     result = input=> (input = input.split(' '), [...input.filter(s=>/^[a-z]/.test(s)).sort(), ...input.filter(s=>/^[A-Z]/.test(s)).sort((a,b)=>a===b ? 0 : a < b ? 1 : -1)].join(' '))

If any punctuation "can" be discarded - it isn't.

This if is "must" be discarded:

     result = input=> (input = input.replace(/[^a-zA-Z\s]/g, '').split(' '), [...input.filter(s=>/^[a-z]/.test(s)).sort(), ...input.filter(s=>/^[A-Z]/.test(s)).sort((a,b)=>a===b ? 0 : a < b ? 1 : -1)].join(' '))
code of conduct - report abuse