Code:
const emptyStringTestArray = [
{ title: 'b' },
{ title: '' },
{ title: 'a' }
]
const nullTestArray = [
{ title: 'b' },
{ title: null },
{ title: 'a' }
]
console.log(emptyStringTestArray.sort(international('title')))
console.log(nullTestArray.sort(international('title')))
Output:
[
{ title: '' },
{ title: 'a' },
{ title: 'b' }
]
[
{ title: null },
{ title: 'a' },
{ title: 'b' }
]
Expected output:
[
{ title: 'a' },
{ title: 'b' },
{ title: '' }
]
[
{ title: 'a' },
{ title: 'b' },
{ title: null }
]
Since it's sorting by string alphabetically, I'd expect to see empty string or null values at the end of the array, not at the beginning.
Code:
Output:
Expected output:
Since it's sorting by string alphabetically, I'd expect to see empty string or null values at the end of the array, not at the beginning.