# Sort output of diff --stat?

4 messages from 2018-10-17 to 2018-10-17. Participants: Robert Dailey, Jeff King.
Thread: https://gitlist.dev/t/49599

## Robert Dailey, 2018-10-17 18:15

Subject: Sort output of diff --stat?
Message-ID: <CAHd499BSVRytaFKOUhE=A4Zv+MMx=uKrWKUcT13QwzOCZWhEtg@mail.gmail.com>
URL: https://gitlist.dev/e/CAHd499BSVRytaFKOUhE%3DA4Zv%2BMMx%3DuKrWKUcT13QwzOCZWhEtg%40mail.gmail.com

```
I'd like to sort the output of `git diff --stat` such that files are
listed in descending order based on number of lines changed. The
closest solution I've found online[1] has several readability issues.
I'd rather see a built-in solution in git, if one exists. Can anyone
recommend a solution?

[1]: https://gist.github.com/jakub-g/7599177

```

## Jeff King, 2018-10-17 18:47

Subject: Re: Sort output of diff --stat?
Message-ID: <20181017184720.GF28326@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20181017184720.GF28326%40sigill.intra.peff.net
In-Reply-To: <CAHd499BSVRytaFKOUhE=A4Zv+MMx=uKrWKUcT13QwzOCZWhEtg@mail.gmail.com>

```
On Wed, Oct 17, 2018 at 01:15:18PM -0500, Robert Dailey wrote:

> I'd like to sort the output of `git diff --stat` such that files are
> listed in descending order based on number of lines changed. The
> closest solution I've found online[1] has several readability issues.
> I'd rather see a built-in solution in git, if one exists. Can anyone
> recommend a solution?

Hmm, I feel like another person asked for this recently, but I can't
seem to find the thread.

Anyway, no, I don't think there's a solution short of parsing the output
(you could parse --numstat, which is at least sane, but then you'd have
to generate your own visual diffstat, which has a lot of corner cases).

We have --orderfile, but that's about a static order based on filename.
It seems reasonable to me for "--stat" to learn an option to sort (that
would not affect, say, the total diff order, since sorting by line count
makes very little sense for most other formats).

-Peff

```

## Robert Dailey, 2018-10-17 19:21

Subject: Re: Sort output of diff --stat?
Message-ID: <CAHd499Ci-DTtv=zKBY-9N60qS9TxerckHNzkOkeiZmUp4jDq_Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAHd499Ci-DTtv%3DzKBY-9N60qS9TxerckHNzkOkeiZmUp4jDq_Q%40mail.gmail.com
In-Reply-To: <20181017184720.GF28326@sigill.intra.peff.net>

```
On Wed, Oct 17, 2018 at 1:47 PM Jeff King <peff@peff.net> wrote:
> Hmm, I feel like another person asked for this recently, but I can't
> seem to find the thread.

Is it this one?
https://www.mail-archive.com/git@vger.kernel.org/msg159212.html

That's the only one I was able to find, but no one replied. Thanks for
your insight. I didn't get my hopes up, but maybe someday it'll be
added.

```

## Jeff King, 2018-10-17 19:25

Subject: Re: Sort output of diff --stat?
Message-ID: <20181017192546.GA31563@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20181017192546.GA31563%40sigill.intra.peff.net
In-Reply-To: <CAHd499Ci-DTtv=zKBY-9N60qS9TxerckHNzkOkeiZmUp4jDq_Q@mail.gmail.com>

```
On Wed, Oct 17, 2018 at 02:21:57PM -0500, Robert Dailey wrote:

> On Wed, Oct 17, 2018 at 1:47 PM Jeff King <peff@peff.net> wrote:
> > Hmm, I feel like another person asked for this recently, but I can't
> > seem to find the thread.
> 
> Is it this one?
> https://www.mail-archive.com/git@vger.kernel.org/msg159212.html
> 
> That's the only one I was able to find, but no one replied. Thanks for
> your insight. I didn't get my hopes up, but maybe someday it'll be
> added.

Ah, yeah, that's the one. For some reason I thought I had replied, but
obviously I did not. ;)

-Peff

```
