From a7f0953a4f4855f04797804cf3083c4b56d838c3 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 14 Jan 2013 15:16:28 +0100 Subject: [PATCH] Make niceSort a wrapper over niceSortKey id Currently, niceSort behaves differently than niceSortKey in cases where the parsed groups are equal but the original not, as it uses both members of the tuple as opposed to just the first one. Both niceSortKey and the Python code use only the first one, so in corner cases we can have different behaviour of these functions. To rectify this, we change niceSort to be a simple wrapper over "niceSortKey id", so that we get consistent behaviour. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- src/Ganeti/Utils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Ganeti/Utils.hs b/src/Ganeti/Utils.hs index e92a70d68..419782645 100644 --- a/src/Ganeti/Utils.hs +++ b/src/Ganeti/Utils.hs @@ -2,7 +2,7 @@ {- -Copyright (C) 2009, 2010, 2011, 2012 Google Inc. +Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -267,7 +267,7 @@ we only need one extra step of dropping the key at the end. -} niceSort :: [String] -> [String] -niceSort = map snd . sort . map (\s -> (fst $ extractKey [] s, s)) +niceSort = niceSortKey id -- | Key-version of 'niceSort'. We use 'sortBy' and @compare `on` fst@ -- since we don't want to add an ordering constraint on the /a/ type, -- GitLab