message-ordering.ts 342 B

12345678
  1. import { WrappedMessage } from "../../interfaces/general.interface";
  2. export function sortMessageBasedOnDate(array: WrappedMessage[]): WrappedMessage[] {
  3. console.log(`Sorting ${array.length} messages....`)
  4. return array.sort((a, b) => {
  5. return new Date(a.timeReceived).getTime() - new Date(b.timeReceived).getTime();
  6. });
  7. }