# sortTimes

Industry: Core

## Signature

```ts
sortTimes(times: string[], order?: "asc" | "desc"): string[]
```

Sort an array of PlainTime values in ascending or descending order.

- Returns empty array if no valid times.
- Validation is performed on each item in the array.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `times` | `string[]` | Array of ISO PlainTime strings (e.g. "14:30:00") |
| `order` | `"asc"` \| `"desc"` | "asc" for ascending (earliest first) \| "desc" for descending (latest first) |

## Returns

Sorted array of time strings

## Examples

```ts
import { sortTimes } from "@northguild/gmt/plain/calculate";

sortTimes(["14:30:00", "09:00:00", "20:45:00"]) // ["09:00:00", "14:30:00", "20:45:00"]
```

## Source

[plain/calculate/sortTimes.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/plain/calculate/sortTimes.ts)
