Let's Sort it Out (in JavaScript)

Issue:
We are converting payroll history into Lawson S3 via IPA and the order of the fields in each row don't line up with the sort order we need them to be in.

The first 6 fields are Record Type, Company, Employee, Process Level, Department and Check ID but they need to be sorted by Company, Employee, Check ID, Record Type, Process Level and Department.

Solution:
The quick method I used was to create the output data with the first 6 fields in the order I needed to sort them in and then used the JavaScript sort() function to sort the array.

That required me to then to read through the data output again, placing each field in it's correct import order.

Not just answers, providing solutions