Sort dict keys into list
<p>I have a dictionary containing IP addresses and hd space for each IP. </p>

<p>{'192.168.100.102': '7.3G', '192.168.100.103': '3.5G', '192.168.100.101': '7.4G', '192.168.100.107': '17G'} </p>

<p>I want to take three IPs with the greatest space and put them into a list. Is this possible?</p>

<p>Slice off the trailing <code>'G'</code> part from the values and convert them to <code>float</code> in the <em>sort key</em>:</p>

<pre><code>ips = {'192.168.100.102': '7.3G', '192.168.100.103': '3.5G', '192.168.100.101': '7.4G', '192.168.100.107': '17G'}

sorted_ips = sorted(ips, key=lambda x: float(ips[x][:-1]), reverse=True)[:3]
print(sorted_ips)
# ['192.168.100.107', '192.168.100.101', '192.168.100.102']
</code></pre>

python dictionary