Skip to content

Commit

Permalink
Merge pull request #1010 from 5sControl/fix/902-zones-sort
Browse files Browse the repository at this point in the history
fix: zones names sort
  • Loading branch information
SergBily authored Jan 22, 2025
2 parents 72ea239 + 4a27aad commit 6520672
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/pages/camera/modal/zones/zoneList/zoneList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ export const ZoneList = ({
<div className={styles.list}>
{[...cameraZones]
.sort((a, b) => {
const hasNumberA = /\d+/.test(a.name);
const hasNumberB = /\d+/.test(b.name);
const isNumberA = /^\d+/.test(a.name);
const isNumberB = /^\d+/.test(b.name);

if (hasNumberA && !hasNumberB) return 1;
if (!hasNumberA && hasNumberB) return -1;
if (isNumberA && isNumberB) return Number(a.name) - Number(b.name);

return a.name.localeCompare(b.name);
})
Expand Down

0 comments on commit 6520672

Please sign in to comment.