Added optimized code
Used correct sort_by
Merge branch 'master' into opt

Added optimized code into rendering views.