Skip to content

After sorting, empty strings are at the beginning of the sorted array #7

@vladshcherbin

Description

@vladshcherbin
const array = [
  { title: 'b' },
  { title: '' },
  { title: 'a' }
]

console.log(array.sort(sortBy('title')))

Output:

[
  { title: '' },
  { title: 'a' },
  { title: 'b' }
]

Expected output:

Since it's sorting by string, I'd expect empty strings to be last in the array:

[
  { title: 'a' },
  { title: 'b' },
  { title: '' }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions