gemini.git

going-flying.com gemini git repository

summary

tree

log

refs

4e4f342bc832ef08e7dfa2301a1b00ca23be2bb2 - Matthew Ernisse - 1596384574

why sort twice when I can just sort *later*

view tree

view raw

diff --git a/files/thoughts-to-gemini.py b/files/thoughts-to-gemini.py
index 812b2c6..55906e7 100755
--- a/files/thoughts-to-gemini.py
+++ b/files/thoughts-to-gemini.py
@@ -171,21 +171,17 @@ class Thoughts(object):
 			with open(t_json, 'r', encoding='utf-8') as fd:
 				self.thoughts = json.load(fd)
 
-		self.thoughts.sort(key=lambda k: k['id'], reverse=True)
 		if len(self.thoughts) != 0:
 			local_newest = self.thoughts[0]['id']
 			if self.api.newest > local_newest:
 				_t = ThoughtApi(local_newest)
-				thoughts = list(_t.thoughts)
-				thoughts.sort(
-					key=lambda k: k['id'],
-					reverse=True
-				)
-				self.thoughts.extend(thoughts)
+				self.thoughts.extend(_t.thoughts)
 		else:
 			_t = ThoughtApi()
 			self.thoughts = list(_t.thoughts)
 
+		self.thoughts.sort(key=lambda k: k['id'], reverse=True)
+
 		with open(t_json, 'w', encoding='utf-8') as fd:
 			json.dump(
 				self.thoughts,