Fix #600 Now the CSV export works properly

This commit sorts the keys for the header of the CSV file, and returns
the value for each key properly