The simplest thing to do is to delete the configuration file, disconnect and let the device create a new one. Then you make you configuration changes using the UI. And hopefully, the collections sorting line will already be there.
If you want to try and clean it up, there are two types of lines:
defines a section. These should be the only things on a line.
There is one
for each setting. The "settingName" will have no spaces. The "value" will only have spaces if the it is enclosed in double quotes.
So, the "\n" are new lines and can be removed and the line split there. Then remove all the spaces except those in a value enclosed in quotes.
I know of only two ways to set the sort for all the collections. The manual way is to open them all and set the value. The other way is for collections that are for series. My Kobo Utilities plugin for calibre has an option to order the series collections and set the sort sort for them to "Date added".