I don't think there is an easy way.
do you need to sort time stretching over more than one day? then I would store the raw unix timestamp. then format it when you display the stored times.
another option would be to store the time in 24 hour in the y=0 element of the array and the 12 hour format in the y=1 element. then when you sort the array on the x axis it will sort the way you want and display from the second element.