Q:

can't order results by distance using Google Api

I am making a call into this URL: https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=60.16915,24.9293937&radius=20000&keyword=k+rauta&rankBy=distance&key=KEY
For some reason I am unable to order result by closest shop the first. 
Like in documentation from https://developers.google.com/maps/documentation/javascript/places#place_search_requests I added rankBy=distance but still it does not seem the result is ordered correctly! 
I removed radius parameter as well but then I get no result found at all! 
Any idea what I am missing here? 

A:

If I read the documentation you mentioned:

google.maps.places. RankBy. DISTANCE.  This option sorts results in ascending order by their distance from the specified location (required).  Note that you cannot specify a custom bounds and/or radius if you specify RankBy. DISTANCE.  When you specify RankBy. DISTANCE, one or more of keyword, name, or type is required. 

Adapt your request with the above and it will work. 
Edit:
You are obviously mixing 2 different things (sorry I didn't see that at first).  The Places Library to which you pointed your documentation link, and the Places API Web Service which is a different thing.  
They both are very similar but there is at least one difference: the rankBy parameter is rankby in the web service.  Note the uppercase/lowercase B.
So this will work: https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=60.16915,24.9293937&keyword=k+rauta&name=k+rauta&type=hardware_store&rankby=distance&key=your_api_key
Also note that your last attempt (link in your comment) returns INVALID_REQUEST and not ZERO_RESULTS or anything else which should help you understand there is problem with your request, and not with the fact that there is no data to return...

