From 5e58c25aa43207fac8abb84c82e22e2045b91ec4 Mon Sep 17 00:00:00 2001 From: Dawid 'DeyV' Polak Date: Sun, 29 Jul 2018 13:22:11 +0200 Subject: [PATCH] natural sort (#474) Former-commit-id: 9865271f38824fd4762253014a7855ee087d315f [formerly 17c1a5f7e2cbbea4f01ba394f6ae76ded22594f3] [formerly 2087a30cb8fa514b33d99fb9797a0751a8f532cd [formerly 202c9c97e53ee04afafc268abebe9ba8dd3aa157]] Former-commit-id: 513ed21a74e590d062f0974b0ea7af7381162df9 [formerly 3fb2617b7aa05abe93460e2ab25ba2369ce68095] Former-commit-id: a038eda5003c044eeceeea46539f3673ebc16f95 --- Gopkg.lock | 6 ++++++ Gopkg.toml | 4 ++++ file.go | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Gopkg.lock b/Gopkg.lock index e69f5fcb..33255e1f 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -214,6 +214,12 @@ revision = "c3beff4c2358b44d0493c7dda585e7db7ff28ae6" version = "v1.7.6" +[[projects]] + branch = "master" + name = "github.com/maruel/natural" + packages = ["."] + revision = "dbcb3e2e8cf10eb839718ba666ef1e21b1c8b847" + [[projects]] name = "github.com/mholt/archiver" packages = ["."] diff --git a/Gopkg.toml b/Gopkg.toml index 22b5603f..479c539b 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -61,6 +61,10 @@ name = "gopkg.in/natefinch/lumberjack.v2" version = "2.1.0" +[[constraint]] + branch = "master" + name = "github.com/maruel/natural" + [[override]] name = "github.com/russross/blackfriday" version = "^1.0.0" diff --git a/file.go b/file.go index 7e34d1ff..1aa3ebd4 100644 --- a/file.go +++ b/file.go @@ -20,6 +20,7 @@ import ( "time" "github.com/gohugoio/hugo/parser" + "github.com/maruel/natural" ) // File contains the information about a particular file or directory. @@ -372,7 +373,7 @@ func (l byName) Less(i, j int) bool { return false } - return strings.ToLower(l.Items[i].Name) < strings.ToLower(l.Items[j].Name) + return natural.Less(l.Items[i].Name, l.Items[j].Name) } // By Size