fix: ordenacao numerica natural para marca de pecas (1, 2, 3... 10 em vez de alfabetica)
This commit is contained in:
@@ -120,13 +120,18 @@ export const usePecasTable = (pecas: Peca[]) => {
|
||||
}
|
||||
|
||||
if (typeof aValue === 'string' && typeof bValue === 'string') {
|
||||
const comparison = aValue.localeCompare(bValue);
|
||||
const comparison = aValue.localeCompare(bValue, undefined, { numeric: true, sensitivity: 'base' });
|
||||
return sortOrder === 'asc' ? comparison : -comparison;
|
||||
}
|
||||
|
||||
if (typeof aValue === 'number' && typeof bValue === 'number') {
|
||||
return sortOrder === 'asc' ? aValue - bValue : bValue - aValue;
|
||||
}
|
||||
|
||||
if (aValue != null && bValue != null) {
|
||||
const comparison = String(aValue).localeCompare(String(bValue), undefined, { numeric: true, sensitivity: 'base' });
|
||||
return sortOrder === 'asc' ? comparison : -comparison;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user