From cf4d4a2e9162eb75d703756489c5384e86344050 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Sun, 2 Dec 2018 22:05:45 -0600 Subject: [PATCH] Use semverCompare on version column --- manage.html | 1 + manage/sort.js | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/manage.html b/manage.html index 640ae3a4..41c11a60 100644 --- a/manage.html +++ b/manage.html @@ -172,6 +172,7 @@ + diff --git a/manage/sort.js b/manage/sort.js index e3739772..6005bc61 100644 --- a/manage/sort.js +++ b/manage/sort.js @@ -1,4 +1,4 @@ -/* global installed t $ prefs */ +/* global installed t $ prefs semverCompare */ /* exported sorter */ 'use strict'; @@ -16,6 +16,7 @@ const sorter = (() => { const sorterType = { alpha: (a, b) => a < b ? -1 : a === b ? 0 : 1, number: (a, b) => (a || 0) - (b || 0), + semver: (a, b) => semverCompare(a, b) }; const tagData = { @@ -41,12 +42,8 @@ const sorter = (() => { }, version: { text: '#', - parse: ({style}) => (style.usercssData && style.usercssData.version || '') - .split(/[.-]/) - .splice(0, 3) // ignore extra labels; e.g. 1.2.3-beta.1 - .map(n => n ? n.padStart(4, '0') : '') - .join(''), - sorter: sorterType.number + parse: ({style}) => (style.usercssData && style.usercssData.version || ''), + sorter: sorterType.semver }, dateInstalled: { text: t('dateInstalled'),