import { CalendarEvent } from './CalendarEvent' ; import { Event } from './Event' ; param a param b returns export type SortEvent < T , M > = ( a : CalendarEvent < T , M > , b : CalendarEvent < T , M > ) => number ; /**
 * A class with [[SortEvent]] functions and functions which accept other
 * [[SortEvent]]s and return a new [[SortEvent]].
 *
 * ```typescript
 * // Sorts full day events first, then events in descending order based on start time.
 * Sorts.List([Sorts.FullDay, Sorts.Desc(Sorts.Start)]);
 * ```
 */ export class Sorts { param a param b returns see public static Start < T , M > ( a , b ) { return a . time . start . time - b . time . start . time ; } param a param b returns see public static End < T , M > ( a , b ) { return a . time . end . time - b . time . end . time ; } param a param b returns see public static FullDay < T , M > ( a , b ) { const af = a . fullDay ? 0 : 1 ; const bf = b . fullDay ? 0 : 1 ; return af - bf ; } param a param b returns see see public static Duration < T , M > ( a , b ) { return a . time . millis ( ) - b . time . millis ( ) ; } param sorter returns public static Desc < T , M > ( sorter ) { return ( a , b ) => { return sorter ( b , a ) ; } ; } param getString returns public static Alphabetical < T , M > ( getString ) { return ( a , b ) => { const as = getString ( a . event ) || '' ; const bs = getString ( b . event ) || '' ; return as . localeCompare ( bs ) ; } ; } param getOrder returns public static Ordered < T , M > ( getOrder ) { return ( a , b ) => { const ao = getOrder ( a . event ) ; const bo = getOrder ( b . event ) ; return ao - bo ; } ; } param sorters returns public static List < T , M > ( sorters ) { return ( a , b ) => { for ( const sorter of sorters ) { const compare = sorter ( a , b ) ; if ( compare !== 0 ) { return compare ; } } return 0 ; } ; } }