Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

562 B
Raw Blame
import type { Guide } from '@mimik/core/guides/types';
import type { SortKey } from '../types';

export function sortGuides(guides: Guide[], sort: SortKey): Guide[] {
  const sorted = [...guides];
  switch (sort) {
    case 'recent':
      return sorted.sort((a, b) => b.updatedAt - a.updatedAt);
    case 'oldest':
      return sorted.sort((a, b) => a.updatedAt - b.updatedAt);
    case 'alpha':
      return sorted.sort((a, b) => a.title.localeCompare(b.title));
    case 'steps':
      return sorted.sort((a, b) => b.stepIds.length - a.stepIds.length);
  }
}