@oss-autopilot/core - v1.6.3
    Preparing search index...

    Function byDateDescending

    • Creates a descending date comparator function for use with Array.prototype.sort().

      Items with null or undefined dates are treated as epoch (sorted last).

      Type Parameters

      • T

      Parameters

      • getDate: (item: T) => string | number | null | undefined

        Accessor function that extracts a date value from each item

      Returns (a: T, b: T) => number

      A comparator function that sorts items from newest to oldest

      const prs = [{ createdAt: '2024-01-01' }, { createdAt: '2024-06-15' }];
      prs.sort(byDateDescending(pr => pr.createdAt));
      // [{ createdAt: '2024-06-15' }, { createdAt: '2024-01-01' }]