diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/issue.scm | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/issue.scm b/tests/issue.scm index 22982db..db2595f 100644 --- a/tests/issue.scm +++ b/tests/issue.scm @@ -1,5 +1,5 @@ ;;; tissue --- Text based issue tracker -;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2022, 2023 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of tissue. ;;; @@ -19,6 +19,7 @@ (import (rnrs hashtables) (srfi srfi-64) (srfi srfi-71) + (ice-9 match) (tissue issue)) (define hashtable-prepend! @@ -31,10 +32,20 @@ (@@ (tissue issue) file-details)) (define (hashtable->alist hashtable) + "Convert @var{hashtable} to association list with keys sorted as +strings." (let ((keys values (hashtable-entries hashtable))) - (map cons - (vector->list keys) - (vector->list values)))) + (sort (map cons + (vector->list keys) + (vector->list values)) + (match-lambda* + (((key1 . _) (key2 . _)) + (let ((maybe-symbol->string (lambda (x) + (if (symbol? x) + (symbol->string x) + x)))) + (string<? (maybe-symbol->string key1) + (maybe-symbol->string key2)))))))) (test-begin "issue") |