From 73a2fa49c53ad715bcfc625f164db36cf4fac742 Mon Sep 17 00:00:00 2001
From: Doug Coleman <erg@jobim.local>
Date: Fri, 3 Apr 2009 18:19:45 -0500
Subject: [PATCH] add title sort for use with joe's mp3 player

---
 basis/sorting/title/authors.txt        |  1 +
 basis/sorting/title/title-tests.factor | 40 ++++++++++++++++++++++++++
 basis/sorting/title/title.factor       |  7 +++++
 3 files changed, 48 insertions(+)
 create mode 100644 basis/sorting/title/authors.txt
 create mode 100644 basis/sorting/title/title-tests.factor
 create mode 100644 basis/sorting/title/title.factor

diff --git a/basis/sorting/title/authors.txt b/basis/sorting/title/authors.txt
new file mode 100644
index 0000000000..b4bd0e7b35
--- /dev/null
+++ b/basis/sorting/title/authors.txt
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/sorting/title/title-tests.factor b/basis/sorting/title/title-tests.factor
new file mode 100644
index 0000000000..34d9e90b38
--- /dev/null
+++ b/basis/sorting/title/title-tests.factor
@@ -0,0 +1,40 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test sorting.title ;
+IN: sorting.title.tests
+
+: sort-me ( -- seq )
+    {
+        "The Beatles"
+        "A river runs through it"
+        "Another"
+        "la vida loca"
+        "Basketball"
+        "racquetball"
+        "Los Fujis"
+        "los Fujis"
+        "La cucaracha"
+        "a day to remember"
+        "of mice and men"
+        "on belay"
+        "for the horde"
+    } ;
+[
+    {
+        "Another"
+        "Basketball"
+        "The Beatles"
+        "La cucaracha"
+        "a day to remember"
+        "for the horde"
+        "Los Fujis"
+        "los Fujis"
+        "of mice and men"
+        "on belay"
+        "racquetball"
+        "A river runs through it"
+        "la vida loca"
+    }
+] [
+    sort-me title-sort
+] unit-test
diff --git a/basis/sorting/title/title.factor b/basis/sorting/title/title.factor
new file mode 100644
index 0000000000..dbdbf8a8fb
--- /dev/null
+++ b/basis/sorting/title/title.factor
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: sorting.functor regexp kernel accessors sequences
+unicode.case ;
+IN: sorting.title
+
+<< "title" [ >lower dup R/ ^(the|a|an|el|la|los|las|il) / first-match [ to>> tail-slice ] when* ] define-sorting >>