const[dataValue, setDataValue] = useState([]);
const filter = () => {
let datafil = filterdataArray; // Array Filter Data Here
+ let val = datafil.sort(function (a, b) {
+ let dateA = a.name.toLowerCase();
+ let dateB = b.name.toLowerCase();
+ if (dateA < dateB) {
+ return -1;
+ } else if (dateA > dateB) {
+ return 1;
+ }
+ return 0;
+ });
+ setDataValue(val);
}
const vehicle = [
{ type: 'car', color: 'Red' },
{ type: 'car', color: 'Blue' },
{ type: 'truck', color: 'Black' } ]
vehicle.sort((a, b) => a.type.localeCompare(b.type));
//vehicle.sort(compareFn:(a :vehicle, b :vehicle) => a.type.localeCompare(b.type));