Skip to content

IP addresses sort as floats (192.200 < 192.42) #34

@Krinkle

Description

@Krinkle

IP addresses currently sort the first chunk as a float.

This bug leads, for example, 192.200.2.3 to sorts before 192.42.2.3, instead of after it.

/* Version: 0.8.1 */

['192.200.2.3','192.42.2.3','192.3.2.1'].sort(naturalSort)
// actual>   ["192.200.2.3", "192.3.2.1",  "192.42.2.3"] 
// expected> ["192.3.2.1",   "192.42.2.3", "192.200.2.3"] 

I ran into this when trying out this module as sorting algorithm for Wikipedia's tablesorter code, but it failed out unit tests.

capture

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