Skip to content

Instantly share code, notes, and snippets.

@dorukcan
Last active June 18, 2019 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dorukcan/e6f27b591dfb1402940a0b9c1566c7d5 to your computer and use it in GitHub Desktop.
Save dorukcan/e6f27b591dfb1402940a0b9c1566c7d5 to your computer and use it in GitHub Desktop.
sort elements in a block with descending order
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