Raw
1 export const getMethodOrder = (method: string) => {
2 switch (method) {
3 case "get":
4 return 1
5 case "post":
6 return 2
7 case "delete":
8 return 3
9 default:
10 return 4
11 }
12 }
13
14 export const compareOperations = ({
15 httpMethodA,
16 httpMethodB,
17 summaryA,
18 summaryB,
19 }: {
20 httpMethodA: string
21 httpMethodB: string
22 summaryA: string
23 summaryB: string
24 }) => {
25 const aOrder = getMethodOrder(httpMethodA)
26 const bOrder = getMethodOrder(httpMethodB)
27
28 if (aOrder !== bOrder) {
29 return aOrder - bOrder
30 }
31
32 return summaryA.localeCompare(summaryB)
33 }