DEV Community

Scott Watermasysk
Scott Watermasysk

Posted on • Originally published at on

Sorting Your Gems

I was looking through the source, and the first thing that jumped out at me was the Gemfile was sorted (within each group). This made it much easier to scan and think about their dependencies.

Using Vim, I was able to sort my Gemfile in a couple of seconds.

  1. Select the lines within the group (or all of those outside of a group).
  2. enter command mode (:) and type sort

That’s it. Now, if you were like me, you still sometimes flipflop between ‘ and “ (working on it!), you will need to pick one (“) and do a find and replace %s/'/"/g as well otherwise things will not sort quite right.

Top comments (1)

hopsoft profile image

We do this on CodeFund.

I also do it on most of my side projects. I think it makes sense to sort any list that you need/want to scan visually. Things like permitted strong parameter attributes in your controllers, etc... Sorting helps you find things quickly and detect potential issues (like duplicate entries).