From 77c3fa8eba9d636dab90d40e7fa21cc6422d8a6a Mon Sep 17 00:00:00 2001 From: Borisov Dmitry Date: Mon, 22 Oct 2012 00:03:02 +0600 Subject: [PATCH] Updated sort function Javascript array bubble sort function. Fits jslint grammar requirements --- cripi.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cripi.js diff --git a/cripi.js b/cripi.js new file mode 100644 index 0000000..7646eb5 --- /dev/null +++ b/cripi.js @@ -0,0 +1,14 @@ +function sort(arr) { + 'use strict'; + var i, j, tmp; + for (i = arr.length - 1; i >= 0; i--) { + for (j = 0; j < i; j++) { + if (arr[j] > arr[j + 1]) { + tmp = arr[j]; + arr[j] = arr[j + 1]; + arr[j + 1] = tmp; + } + } + } + return arr; +} \ No newline at end of file