<p>I use below command to sort the pods by age</p>

<pre><code>kubectl get pods --sort-by={metadata.creationTimestamp}
</code></pre>

<p>It shows up pods in descending order. How can we select sorting order like ascending?</p>

<p>Not supported by <code>kubectl</code> or the <code>kube-apiserver</code> as of this writing (AFAIK), but a workaround would be:</p>
<pre><code>$ kubectl get pods --sort-by=.metadata.creationTimestamp | tail -n +2 | tac
</code></pre>
<p>or if tac is not available (MacOS X):</p>
<pre><code>$ kubectl get pods --sort-by=.metadata.creationTimestamp | tail -n +2 | tail -r
</code></pre>
<p>If you want the header:</p>
<pre><code>$ echo 'NAME                                                              READY   STATUS             RESTARTS   AGE' | \
 kubectl get pods --sort-by=.metadata.creationTimestamp | tail -n +2 | tac
</code></pre>
<p>You might just have to adjust the tabs on the header accordingly. Or if you don't want to use <code>tail -n +2</code> you can use <code>--no-headers</code>. For example:</p>
<pre><code>$ kubectl get pods --sort-by=.metadata.creationTimestamp --no-headers | tac
</code></pre>
