diff --git a/comments-api/app.py b/comments-api/app.py index b6a3312..4d6f209 100644 --- a/comments-api/app.py +++ b/comments-api/app.py @@ -151,7 +151,9 @@ class CommentsResource(flask_restful.Resource): if args['sort_order'] == 'random': q = q.order_by(sqlalchemy.func.random()) elif args['sort_by']: - col = getattr(Comment, args['sort_by'], None) + col = getattr(Association, args['sort_by'], None) + if not col: + col = getattr(Comment, args['sort_by'], None) if col: if args['sort_order']: order_by = getattr(col, args['sort_order'], None)