Implement and test sorting by query similarity.

Add some getters and setters.
Test sorting with equal weights in query.