xlab / handysort

Alphanumeric string sorting algorithm implementation in Go
MIT License
24 stars 3 forks source link

Odd Failure Case #1

Closed johnrs closed 9 years ago

johnrs commented 9 years ago

I ran across this result by accident. It is very sensitive to the amount and position of the data.

[]string{"a", "a", "a", "a1", "a1", "a1", "a1", "a1x"} ==> [a a a a1 a1x a1 a1 a1]

xlab commented 9 years ago

Can't reproduce

package main

import (
    "log"
    "sort"

    "github.com/xlab/handysort"
)

func main() {
    a := []string{"a", "a", "a", "a1", "a1", "a1", "a1", "a1x"}
    sort.Sort(handysort.Strings(a))
    log.Println(a) // => [a a a a1 a1 a1 a1 a1x]
}
johnrs commented 9 years ago

Strange! Here is what I see when I run the exact code you posted.

2015/04/12 13:17:42 [a a a a1 a1x a1 a1 a1]

I'm running ver 1.4.2 windows/amd64 on Windows 7.

xlab commented 9 years ago

Alright, I've rearranged the input, bug showed itself up.

xlab commented 9 years ago

Thanks for these reports.