Return shared queries in order of accessed time(with tests)