<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>aereal</author_name>
  <author_url>https://blog.hatena.ne.jp/aereal/</author_url>
  <blog_title>Sexually Knowing</blog_title>
  <blog_url>https://this.aereal.org/</blog_url>
  <categories>
    <anon>ruby</anon>
  </categories>
  <description>hash = {:a =&gt; 30, :b =&gt; 50, :c =&gt; 40, :d =&gt; 20} hash.sort_by {|k, v| v }.reverse キーを単語、値を単語の出現回数とするハッシュをつくっていじくりまわしたりすることがある。そして出現回数でソートして Array#reverse で昇順に、ということをやることがある。ふと、そういうコードを書いていて、 Enumerable#sort_by の段階で大小比較を反転できればいいんじゃないか、ということに思い至り、数値 (Numeric) の比較なら Numeric#-@ を使えばよい気がする。 hash.sort_by {…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fthis.aereal.org%2Fentry%2F20100603%2F1275576789&quot; title=&quot; Enumerable#sort_by.reverse - Sexually Knowing&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2010-06-03 23:53:09</published>
  <title> Enumerable#sort_by.reverse</title>
  <type>rich</type>
  <url>https://this.aereal.org/entry/20100603/1275576789</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
