From 202c9c97e53ee04afafc268abebe9ba8dd3aa157 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) --- 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