Skip to content

Conversation

@dominictobias
Copy link

@dominictobias dominictobias commented Mar 12, 2019

Hi,

This achieves the same thing as #43 but doesn't put the keys in a weird order (by length), instead it does a lexical sort (i.e. 0-1 A-Z)

['world.lorem.ipsum',
'apple.zebra',
'apple',
'apple.aa',
'world.lorem.dolor',
'0test',
'world'].sort()

Becomes:

["0test", "apple", "apple.aa", "apple.zebra", "world", "world.lorem.dolor", "world.lorem.ipsum"]

Rather than:

['world.lorem.ipsum',
'apple.zebra',
'apple',
'apple.aa',
'world.lorem.dolor',
'0test',
'world'].sort(function(keyA, keyB) {
    return keyA.length - keyB.length
  })

// equals:

["apple", "0test", "world", "apple.aa", "apple.zebra", "world.lorem.ipsum", "world.lorem.dolor"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant