summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorctucx <c@ctu.cx>2020-09-15 17:02:06 +0200
committerctucx <c@ctu.cx>2020-09-15 17:02:06 +0200
commit1ae809fade110907393a9c0fdf6ab825a92c9a7a (patch)
tree02c6d016f8cb1cdfdea6203f645724de7c49ce37
parent28c67b971e496a6c4c281b2dec0874259265af3d (diff)
downloadnimtradfri-1ae809fade110907393a9c0fdf6ab825a92c9a7a.tar.gz
nimtradfri-1ae809fade110907393a9c0fdf6ab825a92c9a7a.tar.bz2
nimtradfri-1ae809fade110907393a9c0fdf6ab825a92c9a7a.zip
update
-rw-r--r--devices.nim5
-rw-r--r--groups.nim9
2 files changed, 12 insertions, 2 deletions
diff --git a/devices.nim b/devices.nim
index 5f313e1..7b20690 100644
--- a/devices.nim
+++ b/devices.nim
@@ -1,4 +1,4 @@
-import json, strutils, options
+import json, strutils, options, algorithm
import coapClient
import gatewayTypes, deviceTypes
@@ -210,3 +210,6 @@ proc getDevices* (gatewayRef: TradfriGatewayRef): seq[TradfriDevice] =
for id in request:
result.add(getDevice(gatewayRef, id.getInt))
+
+ result.sort do (x, y: TradfriDevice) -> int:
+ result = cmp(x.id, y.id)
diff --git a/groups.nim b/groups.nim
index 43567a1..eb257ba 100644
--- a/groups.nim
+++ b/groups.nim
@@ -1,4 +1,4 @@
-import json, strutils, sequtils, options
+import json, strutils, sequtils, options, algorithm
import coapClient
import gatewayTypes, groupTypes, deviceTypes
@@ -27,6 +27,9 @@ proc getGroup* (gatewayRef: TradfriGatewayRef, groupId: int): TradfriGroup =
for deviceId in request[ParameterDeviceIds]["15002"]["9003"]:
devices.add(gatewayRef.getDevice(deviceId.getInt))
+ devices.sort do (x, y: TradfriDevice) -> int:
+ result = cmp(x.id, y.id)
+
result = TradfriGroup(
gatewayRef: gatewayRef,
name: request[ParameterName].getStr,
@@ -46,3 +49,7 @@ proc getGroups* (gatewayRef: TradfriGatewayRef): seq[TradfriGroup] =
for id in request:
result.add(getGroup(gatewayRef, id.getInt))
+
+ result.sort do (x, y: TradfriGroup) -> int:
+ result = cmp(x.id, y.id)
+