# betterdocs/4.9.5/react-src/admin/faq-builder/utils/reOrder.js

BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ &amp; Chatbot, version 4.9.5. 28 lines.

- Page: https://pluginprobe.com/plugins/betterdocs/4.9.5/code/react-src/admin/faq-builder/utils/reOrder.js
- Raw: https://pluginprobe.com/plugins/betterdocs/4.9.5/raw/react-src/admin/faq-builder/utils/reOrder.js
- Modified: 2026-10-12T10:07:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/betterdocs/4.9.5/code/react-src/admin/faq-builder/utils/reOrder.js#L10-L20`.

```javascript
export const categoryOrdering = (result, sortableCategories, currentPage, perPage) => {
    const cats = sortableCategories.map((cat) => ({
        id: cat?.id,
        current_position: cat?.meta?.order[0],
    }));
    let reOrderedCats = [];
    let startIndex    = currentPage != 1 ? ((( perPage * currentPage ) + 1) - 10) : currentPage;
    cats?.splice(result?.destination?.index, 0, ...cats?.splice(result?.source?.index, 1));
    for( let i = 0; i < cats?.length; i++ ) {
        reOrderedCats.push({
            ...cats[i],
            updated_position: (startIndex).toString(),
        });
        startIndex++;
    }
    return reOrderedCats;
}

export const faqOrdering = (result, sortedFaqList) => {
  const startIndex = result.source.index;
  const endIndex = result.destination.index;

  let data = [...sortedFaqList];
  let [removed] = data.splice(startIndex, 1);
  data.splice(endIndex, 0, removed);
  return data;
};

```
