The purpose of this script is to demonstrate a sort function (@26-32) that reorders an array (dates => sortedDates
) based on proximity to a specified date (search
and d3o
), with a bias towards future dates.
Use case includes searching for a history-related item in the past given a date. This functions serves to find the closest item relative to a date resolved from speech. For example, it is the assumption that when a user requests an item by date using "Last Tuesday", where no item exists on the date resolved from "Last Tuesday", that the user's bias will be towards the closest date more future to the one specified. This is based off of the additional assumption that the requester's memory is more likely to mistake "Wednesday" for "Tuesday", rather than "Monday" for "Tuesday" because "Wednesday" is closer to the current date, and thus their memory of it was likely to be more vivid.
These assumptions are not supported by any studies or scientif