From 120cfe1e9ef04942091058eadf49281f41aafecd Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 1 Oct 2014 09:03:48 +0100 Subject: Improve floor sorting Now works for level 10, and 11 in the Maths building. --- src/leaflet-soton.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js index 2a52b16..36650e4 100644 --- a/src/leaflet-soton.js +++ b/src/leaflet-soton.js @@ -1435,8 +1435,20 @@ SELECT * WHERE {\ } } - var floor_ids = Object.keys( floors ); - floor_ids.sort(); + var floor_ids = Object.keys(floors); + + floor_ids.sort(function(a, b) { + if (a === "Unknown") return 1; + if (b === "Unknown") return -1; + + a = parseInt(a, 10); + b = parseInt(b, 10); + + if (a < b) { + return -1; + } + return 1; + }); floor_ids.forEach(function(floor_id) { var h4 = document.createElement( "h4" ); -- cgit v1.2.3