Skip to content

Commit

Permalink
use a better natural sort library
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoisaiah committed Jan 30, 2025
1 parent 9d81a4c commit 010261a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ require (
)

require (
github.com/MagicalTux/natsort v1.0.1
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/djherbis/times v1.6.0
github.com/jessevdk/go-flags v1.6.1
github.com/jinzhu/copier v0.4.0
github.com/maruel/natural v1.1.1
github.com/mattn/go-isatty v0.0.20
github.com/olekukonko/tablewriter v0.0.5
github.com/sebdah/goldie/v2 v2.5.5
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ atomicgo.dev/keyboard v0.2.9 h1:tOsIid3nlPLZ3lwgG8KZMp/SFmr7P0ssEN5JUsm78K8=
atomicgo.dev/keyboard v0.2.9/go.mod h1:BC4w9g00XkxH/f1HXhW2sXmJFOCWbKn9xrOunSFtExQ=
atomicgo.dev/schedule v0.1.0 h1:nTthAbhZS5YZmgYbb2+DH8uQIZcTlIrd4eYr3UQxEjs=
atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU=
github.com/MagicalTux/natsort v1.0.1 h1:X4vYXdWJ/FsG0j/INdRQQNCqsD7pW9DgWjsf0lubNPQ=
github.com/MagicalTux/natsort v1.0.1/go.mod h1:o8tj+E5+WJ+DiY05o+smMbgfBPGEM+86rMKaN2i2rKE=
github.com/MarvinJWendt/testza v0.1.0/go.mod h1:7AxNvlfeHP7Z/hDQ5JtE3OKYT3XFUeLCDE2DQninSqs=
github.com/MarvinJWendt/testza v0.2.1/go.mod h1:God7bhG8n6uQxwdScay+gjm9/LnO4D3kkcZX4hv9Rp8=
github.com/MarvinJWendt/testza v0.2.8/go.mod h1:nwIcjmr0Zz+Rcwfh3/4UhBp7ePKVhuBExvZqnKYWlII=
Expand Down Expand Up @@ -56,8 +54,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4=
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
github.com/maruel/natural v1.1.0 h1:2z1NgP/Vae+gYrtC0VuvrTJ6U35OuyUqDdfluLqMWuQ=
github.com/maruel/natural v1.1.0/go.mod h1:eFVhYCcUOfZFxXoDZam8Ktya72wa79fNC3lc/leA0DQ=
github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo=
github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
Expand Down
6 changes: 3 additions & 3 deletions internal/sortfiles/sortfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"gopkg.in/djherbis/times.v1"

"github.com/MagicalTux/natsort"
"github.com/maruel/natural"
"github.com/pterm/pterm"

"github.com/ayoisaiah/f2/v2/internal/config"
Expand Down Expand Up @@ -230,10 +230,10 @@ func Natural(changes file.Changes, reverseSort bool) {
}

if reverseSort {
return !natsort.Compare(sourcePathA, sourcePathB)
return !natural.Less(sourcePathA, sourcePathB)
}

return natsort.Compare(sourcePathA, sourcePathB)
return natural.Less(sourcePathA, sourcePathB)
})
}

Expand Down

0 comments on commit 010261a

Please sign in to comment.