Fixing hanging protocols matching score issues
This commit is contained in:
1 parent
88e504a010
commit
17f8d87d32
3 files changed
+95
-38
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
OHIF.utils = {};
|
||||
|
||||
// Return the array sorting function for its object's properties
|
||||
OHIF.utils.sortBy = function() {
|
||||
var fields = [].slice.call(arguments),
|
||||
n_fields = fields.length;
|
||||
|
||||
return function(A, B) {
|
||||
var a, b, field, key, primer, reverse, result, i;
|
||||
|
||||
for (i = 0; i < n_fields; i++) {
|
||||
result = 0;
|
||||
field = fields[i];
|
||||
|
||||
key = typeof field === 'string' ? field : field.name;
|
||||
|
||||
a = A[key];
|
||||
b = B[key];
|
||||
|
||||
if (typeof field.primer !== 'undefined') {
|
||||
a = field.primer(a);
|
||||
b = field.primer(b);
|
||||
}
|
||||
|
||||
reverse = (field.reverse) ? -1 : 1;
|
||||
|
||||
if (a < b) {
|
||||
result = reverse * -1;
|
||||
}
|
||||
|
||||
if (a > b) {
|
||||
result = reverse * 1;
|
||||
}
|
||||
|
||||
if (result !== 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user