Consider this nested array of dates and names:
var fDates = [ ['2015-02-03', 'name1'], ['2015-02-04', 'nameg'], ['2015-02-04', 'name5'], ['2015-02-05', 'nameh'], ['1929-03-12', 'name4'], ['2023-07-01', 'name7'], ['2015-02-07', 'name0'], ['2015-02-08', 'nameh'], ['2015-02-15', 'namex'], ['2015-02-09', 'namew'], ['1980-12-23', 'name2'], ['2015-02-12', 'namen'], ['2015-02-13', 'named'], ]
How can I identify those dates that are out of sequence. I don’t care if dates repeat, or skip, I just need the ones out of order. Ie, I should get back:
results = [ ['1929-03-12', 'name4'], ['2023-07-01', 'name7'], ['2015-02-15', 'namex'], ['1980-12-23', 'name2'], ]
(‘Namex’ is less obvious, but it’s not in the general order of the list.)
This appears to be a variation on the Longest Increase Subsequence (LIS) problem, with the caveat that there may be repeated dates in the sequence but shouldn’t ever step backward.
Use case: I have sorted and dated records and need to find the ones where the dates are “suspicious” — perhaps input error — to flag for checking.