I have array of object with this interface
interface Item {
country: string;
cases: number;
deaths: number;
population: number;
}
I want to make sort function
const sortDescending = (type: keyof Item): void => {
data.sort((a, b) => {
return a[type] - b[type];
});
};
Problem that typescript is not allowing me to perform it because of "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type" I understand that I have strings in object and I can't do arithmetic operation with them. how to fix it ?