added custom ordering on entities
fixed potential sql injection issue
refactored to keep code cleaner
Merge pull request #3 from owyongsk/master

added custom ordering on entities