Clock Time Sorter
Sort a list of clock times in ascending or descending order. Supports 12-hour and 24-hour formats with seconds. Paste, sort, copy.
About
Sorting a list of clock times is not a simple alphabetical operation. A naive string sort places 9:00 AM after 10:00 AM because the character 9 has a higher code point than 1. The correct approach converts each time to a canonical numeric value - total seconds since midnight - then sorts on that integer. This tool parses mixed-format inputs (both 24-hour and 12-hour notation, with or without seconds) and produces a correctly ordered list. It handles edge cases such as 12:00 AM (midnight, 0 seconds) and 12:00 PM (noon, 43200 seconds) which frequently cause errors in manual sorting.
Miscalculating time order affects scheduling, log analysis, shift planning, and data pipeline sequencing. A single inversion in a timetable can cascade into missed connections or compliance violations. This tool validates each entry, flags unparseable lines, removes duplicates on request, and exports the result in your preferred format. It approximates no values - every output is deterministic and exact.
Formulas
Each time string is converted to a single integer representing total seconds elapsed since midnight (00:00:00):
Where S is the sort key (total seconds), h is the hour in 24-hour notation (0 - 23), m is the minute (0 - 59), and s is the second (0 - 59). For 12-hour input, the conversion to 24-hour h follows:
Sorting is performed on S using a comparison function: Sa − Sb for ascending, Sb − Sa for descending. Duplicate detection compares S values - two entries with identical S are duplicates regardless of original format.
Reference Data
| Input Format | Example | Parsed As (24h) | Seconds Since Midnight | Notes |
|---|---|---|---|---|
| 24h HH:MM | 14:30 | 14:30:00 | 52200 | Standard ISO-like notation |
| 24h HH:MM:SS | 08:05:33 | 08:05:33 | 29133 | Includes seconds |
| 12h h:MM AM | 9:15 AM | 09:15:00 | 33300 | Leading zero optional |
| 12h hh:MM PM | 02:45 PM | 14:45:00 | 53100 | PM adds 12 hours (except 12 PM) |
| 12h hh:MM:SS AM | 11:59:59 AM | 11:59:59 | 43199 | One second before noon |
| 12h 12:00 AM | 12:00 AM | 00:00:00 | 0 | Midnight - earliest time of day |
| 12h 12:00 PM | 12:00 PM | 12:00:00 | 43200 | Noon - not AM |
| 12h 12:59 PM | 12:59 PM | 12:59:00 | 46740 | Still in the 12 PM hour |
| 12h 12:01 AM | 12:01 AM | 00:01:00 | 60 | Just past midnight |
| 24h 00:00 | 00:00 | 00:00:00 | 0 | Midnight in 24h format |
| 24h 23:59:59 | 23:59:59 | 23:59:59 | 86399 | Last second of the day |
| 24h single-digit hour | 6:30 | 06:30:00 | 23400 | Leading zero optional in 24h |
| Invalid | 25:00 | - | - | Hour > 23 rejected |
| Invalid | 13:00 PM | - | - | 13+ with AM/PM rejected |
| Invalid | abc | - | - | Non-time string rejected |