Sort function added and date/time formatting bug fixed.