/* eslint no-unused-vars: 0 */ import React from 'react'; import BootstrapTable from 'react-bootstrap-table-next'; import Code from 'components/common/code-block'; import { productsGenerator } from 'utils/common'; const products = productsGenerator(); const columns = [{ dataField: 'id', text: 'Product ID', sort: true }, { dataField: 'name', text: 'Product Name', sort: true }, { dataField: 'price', text: 'Product Price' }]; const sourceCode = `\ import BootstrapTable from 'react-bootstrap-table-next'; const columns = [{ dataField: 'id', text: 'Product ID', sort: true }, { dataField: 'name', text: 'Product Name', sort: true }, { dataField: 'price', text: 'Product Price' }]; class OnetimeSortConfiguration extends React.Component { sortFunc = (a, b, order, dataField) => { if (order === 'asc') { return b - a; } return a - b; // desc } render() { const sortOption = { // No need to configure sortFunc per column sortFunc: this.sortFunc, // No need to configure sortCaret per column sortCaret: (order, column) => { if (!order) return (  Desc/Asc); else if (order === 'asc') return (  Desc/Asc); else if (order === 'desc') return (  Desc/Asc); return null; } }; return (
{ sourceCode }
); } } `; export default class OnetimeSortConfiguration extends React.Component { sortFunc = (a, b, order, dataField) => { if (order === 'asc') { return b - a; } return a - b; // desc } render() { const sortOption = { sortFunc: this.sortFunc, sortCaret: (order, column) => { if (!order) return (  Desc/Asc); else if (order === 'asc') return (  Desc/Asc); else if (order === 'desc') return (  Desc/Asc); return null; } }; return (

Reverse Sorting Table

{ sourceCode }
); } }