mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-22 07:48:10 +03:00
Define sortNamed in terms of sortByText rather than the other way around
This commit is contained in:
parent
f4c866e3cf
commit
29e4d6dc5d
@ -52,13 +52,13 @@ sortNames :: [Name] -> [Name]
|
||||
sortNames = sortNamed id
|
||||
|
||||
sortNamed :: (a -> Name) -> [a] -> [a]
|
||||
sortNamed by as = let
|
||||
as' = [ (a, Text.unpack (toText (by a))) | a <- as ]
|
||||
comp (_,s) (_,s2) = RFC5051.compareUnicode s s2
|
||||
in fst <$> sortBy comp as'
|
||||
sortNamed by = sortByText (toText . by)
|
||||
|
||||
sortByText :: (a -> Text) -> [a] -> [a]
|
||||
sortByText by = sortNamed (Name . by)
|
||||
sortByText by as = let
|
||||
as' = [ (a, Text.unpack (by a)) | a <- as ]
|
||||
comp (_,s) (_,s2) = RFC5051.compareUnicode s s2
|
||||
in fst <$> sortBy comp as'
|
||||
|
||||
-- | Like sortNamed, but takes an additional backup comparison function if two
|
||||
-- names are equal.
|
||||
|
Loading…
Reference in New Issue
Block a user