changeset 95:c00c0af1efd2

Sort record types using dictionary sorting
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 07 Feb 2016 18:50:49 +0000
parents 0483ca64eb6b
children f9e57345d7aa
files src/record_types.rs
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/record_types.rs	Sun Feb 07 18:25:45 2016 +0000
+++ b/src/record_types.rs	Sun Feb 07 18:50:49 2016 +0000
@@ -1,6 +1,8 @@
 use std::collections::LinkedList;
 use std::cmp::{Eq, PartialEq, Ordering, PartialOrd};
 
+use sort;
+
 /// A (key,value) pair.
 #[derive(Clone, PartialEq, Eq)]
 pub struct Record {
@@ -18,8 +20,8 @@
 
 impl PartialOrd for Record {
     fn partial_cmp(&self, other: &Record) -> Option<Ordering> {
-        Some(match self.key.cmp(&other.key) {
-            Ordering::Equal => self.value.cmp(&other.value),
+        Some(match sort::dict_string_compare(&self.key, &other.key) {
+            Ordering::Equal => sort::dict_string_compare(&self.value, &other.value),
             o => o,
         })
     }
@@ -27,8 +29,8 @@
 
 impl Ord for Record {
     fn cmp(&self, other: &Record) -> Ordering {
-        match self.key.cmp(&other.key) {
-            Ordering::Equal => self.value.cmp(&other.value),
+        match sort::dict_string_compare(&self.key, &other.key) {
+            Ordering::Equal => sort::dict_string_compare(&self.key, &other.value),
             o => o,
         }
     }
@@ -62,7 +64,7 @@
 
 impl PartialOrd for MultiRecord {
     fn partial_cmp(&self, other: &MultiRecord) -> Option<Ordering> {
-        Some(self.key.cmp(&other.key))
+        Some(sort::dict_string_compare(&self.key, &other.key))
     }
 }