From 9baec63a59d0846ac15bb5752c2dd85d4ccac1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Thu, 16 Apr 2015 20:35:11 +0200 Subject: [PATCH] Sorting frontpagechannels on viewers then on number of songs --- static/js/nochan.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/static/js/nochan.js b/static/js/nochan.js index abcc3347..61cf8340 100755 --- a/static/js/nochan.js +++ b/static/js/nochan.js @@ -55,12 +55,17 @@ String.prototype.capitalizeFirstLetter = function() { function sortFunction(a, b) { - if (a[0] === b[0]) { - return 0; - } - else { - return (a[0] < b[0]) ? 1 : -1; - } + var o1 = a[0]; + var o2 = b[0]; + + var p1 = a[4]; + var p2 = b[4]; + + if (o1 < o2) return 1; + if (o1 > o2) return -1; + if (p1 < p2) return 1; + if (p1 > p2) return -1; + return 0; } $(document).ready(function (){