Skip to content

Commit

Permalink
Fix a bug where posts were rendered in wrong order
Browse files Browse the repository at this point in the history
The `os.listdir` function doesn't guarantee any order.  On OSX, this order is
correct --- on Linux, not so much.  This commit forces the list of posts to be
sorted alphanumerically.
  • Loading branch information
honza committed Mar 24, 2016
1 parent 9669c27 commit 21828e7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion socrates/socrates.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ def load_posts(self):
Get all files from the posts directory, create Post instances and add
them to the self.posts list.
"""
for filename in os.listdir(self.POSTS):
filenames = os.listdir(self.POSTS)
filenames.sort()

for filename in filenames:
if not filename.startswith('.') and not filename.startswith('_'):
p = os.path.join(self.POSTS, filename)
try:
Expand Down

0 comments on commit 21828e7

Please sign in to comment.