Skip to content

Commit

Permalink
[NO CHANGELOG][Add Funds Widget] Add sortRoutesByFastestTime function (
Browse files Browse the repository at this point in the history
  • Loading branch information
mimi-imtbl authored Sep 26, 2024
1 parent 6a9ff40 commit ec6a309
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { RouteData } from '../types';

export const sortRoutesByFastestTime = (routes: RouteData[] | undefined): RouteData[] | undefined => {
if (!routes) return undefined;

return routes.slice().sort((a, b) => {
const timeA = a.route.route.estimate.estimatedRouteDuration;
const timeB = b.route.route.estimate.estimatedRouteDuration;
return timeA - timeB;
});
};

0 comments on commit ec6a309

Please sign in to comment.