From aed50e5b25e5a5c60e4273139e8d003a4e2aa064 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 3 Dec 2008 21:41:34 +0000 Subject: [PATCH] added generic sort routine for objects / fm-objects. defaults to sorting on the "id" column git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4@11395 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/Util.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Open-ILS/web/js/dojo/openils/Util.js b/Open-ILS/web/js/dojo/openils/Util.js index 1e6c384d7b..a421a6fb6b 100644 --- a/Open-ILS/web/js/dojo/openils/Util.js +++ b/Open-ILS/web/js/dojo/openils/Util.js @@ -166,4 +166,16 @@ if(!dojo._hasResource["openils.Util"]) { node.className = className; } + openils.Util.objectSort = function(list, field) { + if(dojo.isArray(list)) { + if(!field) field = 'id'; + return list.sort( + function(a, b) { + if(a[field]() > b[field]()) return 1; + return -1; + } + ); + } + return []; + }; } -- 2.11.0