changeset 2849:050a99108afa

#119 initial code added to provide index-list of sorted values
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 25 Apr 2017 16:19:37 +0100
parents bef3d563d667
children 6c41a874fd21
files js/core.js
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/js/core.js	Tue Apr 25 16:01:27 2017 +0100
+++ b/js/core.js	Tue Apr 25 16:19:37 2017 +0100
@@ -3327,6 +3327,25 @@
         return state;
     };
 
+    this.sortFragmentsByScore = function () {
+        var elements = audioEngineContext.audioObjects.filter(function (elem) {
+            return elem.specification.type !== "outside-reference";
+        });
+        var indexes = [];
+        var i = 0;
+        while (indexes.push(i++) < elements.length);
+        return indexes.sort(function (x, y) {
+            var a = elements[x].interfaceDOM.getValue();
+            var b = elements[y].interfaceDOM.getValue();
+            if (a > b) {
+                return 1;
+            } else if (a < b) {
+                return -1;
+            }
+            return 0;
+        }, elements[0].interfaceDOM.getValue());
+    };
+
     this.storeErrorNode = function (errorMessage) {
         var time = audioEngineContext.timer.getTestTime();
         var node = storage.document.createElement('error');