Closed raphaelrk closed 10 years ago
That code's been bugging me. It was really bloated from failed attempts, and had a bubble sort in it. Here's a nicer version: (Note: 'moves First,Last,Website,GitHub,Twitter,Facebook')
var textarea = document.getElementById('blob_contents'); // the edit area
var itemsToSort = textarea.innerHTML.split('\n'); // the csv lines
itemsToSort.sort(); // sort the items
var printout = "" // string to populate
for(var i = 0; i < itemsToSort.length; i++) printout += itemsToSort[i] + '\n';
console.log(printout); // print out alphabetized doc
:thumbsup:
Here's my javascript automation code for it. Run the code while in your browser's console on the edit page for the csv. It'll print out what should be pasted in the file. It changes the innerHTML because I thought it'd keep one from needing to copy and paste, since github's editor would see you made a change, but I was wrong, it didn't detect a change. There's also more code I wrote for this that edits all the divs in the editor to be alphabetical (this is a visible page change), but GitHub's editor still didn't count it as a file change. Because I was trying this I had to roll my own sorting method since the divs were in a nodelist, not an array.