From 3d73274c8385f669dac69a1efeb2f27eca3ba6f2 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 3 Dec 2008 21:41:10 +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/trunk@11394 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 424793d2b3..761f132c49 100644 --- a/Open-ILS/web/js/dojo/openils/Util.js +++ b/Open-ILS/web/js/dojo/openils/Util.js @@ -168,4 +168,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