[open-ils-commits] r11394 - trunk/Open-ILS/web/js/dojo/openils
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Dec 3 16:41:14 EST 2008
Author: erickson
Date: 2008-12-03 16:41:10 -0500 (Wed, 03 Dec 2008)
New Revision: 11394
Modified:
trunk/Open-ILS/web/js/dojo/openils/Util.js
Log:
added generic sort routine for objects / fm-objects. defaults to sorting on the "id" column
Modified: trunk/Open-ILS/web/js/dojo/openils/Util.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/Util.js 2008-12-03 21:39:47 UTC (rev 11393)
+++ trunk/Open-ILS/web/js/dojo/openils/Util.js 2008-12-03 21:41:10 UTC (rev 11394)
@@ -168,4 +168,16 @@
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 [];
+ };
}
More information about the open-ils-commits
mailing list