frontPanel/src/pages/Questions/AnswerDraggableList/helper.ts
2023-08-25 13:27:43 +03:00

12 lines
239 B
TypeScript

export const reorder = <T>(
list: T[],
startIndex: number,
endIndex: number
): T[] => {
const result = Array.from(list);
const [removed] = result.splice(startIndex, 1);
result.splice(endIndex, 0, removed);
return result;
};