Added sorting and window function to queries

I have added support for sorting by keys and extended the limit function to include offset capability.