-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnatSortTest.html
22 lines (22 loc) · 1.06 KB
/
natSortTest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<html>
<p id="input"></p>
<p id="output"></p>
<p id="timecheck"></p>
<script>
let inputParagraph = document.getElementById("input");
let outputParagraph = document.getElementById("output");
let timeCheckParagraph = document.getElementById("timecheck");
let inputJson = '{"a": 4, "b": 2, "c": 3}';
let input = JSON.parse(inputJson);
// create array from all keys in input
let keys = Object.keys(input);
inputParagraph.innerHTML = keys;
// sort the array
let sortedKeys = keys.sort(function(a, b){return input[a] - input[b]});
outputParagraph.innerHTML = sortedKeys;
let time = new Date() //.toISOString();
let diff = time.getTimezoneOffset();
timeCheckParagraph.innerHTML = time.toISOString() + " " + diff + " " + time.getFullYear() + "-" + time.getMonth() + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + " Uhr";
</script>
</html>