const sorted = (massive:dataType[],name:string,mode:boolean) =>{
switch(name){
case 'id':
if(mode){
const tmp = massive.sort((a, b) => a.id > b.id ? 1 : -1)
return tmp
}
else{
const tmp = massive.sort((a, b) => a.id < b.id ? 1 : -1)
return tmp
};
case 'title':
if(mode){
const tmp = massive.sort((a, b) => a.title > b.title ? 1 : -1)
return tmp
}
else{
const tmp = massive.sort((a, b) => a.title < b.title ? 1 : -1)
return tmp
}
case 'body':
if(mode){
const tmp =massive.sort((a, b) => a.body > b.body ? 1 : -1)
return tmp
}
else{
const tmp = massive.sort((a, b) => a.body < b.body ? 1 : -1)
return tmp
}
default:
return massive
}
}