Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is the full code for you, you have to append all the results to one container and sort in <code>.ajaxComplete</code> event</p> <pre><code>$(document).ready(function () { $("#search").keyup(function () { $("#suggest").empty(); $.getJSON("http://suggestqueries.google.com/complete/search?q=" + $("#search").val() + "&amp;client=chrome&amp;callback=?", function (data) { var suggestion = ""; for (var key in data[1]) { if (data[4]["google:suggesttype"][key] == "NAVIGATION") { suggestion += "&lt;li&gt;&lt;a href='" + data[1][key] + "'&gt;" + data[2][key] + "&lt;/a&gt; &lt;i&gt;(" + data[4]["google:suggestrelevance"][key] + ")&lt;/i&gt;&lt;/li&gt;"; } else { suggestion += "&lt;li&gt;" + data[1][key] + " &lt;i&gt;(" + data[4]["google:suggestrelevance"][key] + ")&lt;/i&gt;&lt;/li&gt;"; } } $("#suggest").append(suggestion); }); $.getJSON("https://www.googleapis.com/freebase/v1/search?query=" + $("#search").val() + "&amp;limit=3&amp;encode=html&amp;callback=?", function (data) { var suggestion2 = ""; for (var key in data.result) { suggestion2 += "&lt;li&gt;" + data.result[key].name + " &lt;i&gt;(" + data.result[key].score * 4 + ")&lt;/i&gt;&lt;/li&gt;"; } $("#suggest").append(suggestion2); }); $(document).ajaxComplete(function (event, xhr, settings) { $("#suggest").html($("#suggest li").sort(function (a, b) { return (parseInt($(a).find("i").html(), 10) &gt; parseInt($(b).find("i").html(), 10)); })); }); }); }); </code></pre> <p><a href="http://jsfiddle.net/rEPf3/8/" rel="nofollow">http://jsfiddle.net/rEPf3/8/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload