1
1
I have written a script using Notepad++, and in it I have hardcoded an array. This is a script which I have expanded on over the years, and thus the array have gotten "unsorted". Let's say that it now looks something like this:
my_array[0] = "bb";
my_array[1] = "aa";
my_array[2] = "cc";
my_array[3] = "ab";
What I want to do is make it look like this instead:
my_array[0] = "aa";
my_array[1] = "ab";
my_array[2] = "bb";
my_array[3] = "cc";
I.e. I want to "sort" the array so it looks nicer in the script-file, and so that it is easier to find any value I may want to alter in it.
Is there any functionality for altering the text in the script in such a manner in Notepad++? If so, how would I go about doing it?
Thanks for the answer. I was hoping there was a simpler way do do it, but unless someone else comes up with a better solution in the next day or so, I'll mark this as the accepted answer. – eirikdaude – 2015-04-12T22:38:05.333
You could also column-select the data ( that is, everything to the rignt of the equal sign), paste it somewhere else, sort it, and paste it back. This, assuming the indices in the array are properly sorted. If that was not the case, I would use Excel to recreate the hard-coded array after sorting the data. – Martin Argerami – 2015-04-13T04:43:58.027
@MartinArgerami: 1) Won't really be a simpler way. 2) I tried that actually, but pasting doesn't seem to work in column mode in NP++ the way I expected it to. Instead of aa,ab,bb,cc being pasted one per line, I got 4 copies of aa,ab,bb,cc. If you can get it to work the way you suggest do let me know, just to satisfy my curiosity. – Karan – 2015-04-13T05:22:03.630
My bad then. I assumed that pasting a column would work. – Martin Argerami – 2015-04-13T10:28:37.780