Last active
June 18, 2019 07:35
-
-
Save dorukcan/e6f27b591dfb1402940a0b9c1566c7d5 to your computer and use it in GitHub Desktop.
sort elements in a block with descending order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var container = document.querySelector('#gwt-debug-logGroupTable tbody'); | |
var items = Array.from(container.querySelectorAll("tr")); | |
var sortable = (item) => { | |
var sortKey = new Date(item.querySelector("td:last-child").textContent); | |
return sortKey.getTime(); | |
}; | |
items = items.sort((a, b) => {return sortable(a) == sortable(b) ? 0 : (sortable(a) < sortable(b) ? 1 : -1)}); | |
container.innerHTML = items.map(item => item.outerHTML).join(""); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment