title: Listing the results of the du command in alphabetical order
body: <p>How can I list the results of the <code>du</code> command in alphabetical order?</p>
  
  <p>I know I can use the <code>find</code> command to list them alphabetically, but without the directory size, I also use the <code>-maxdepth</code> option for both commands so that the listing only goes down one subdirectory. </p>
  
  <p>Here's the question in italics: </p>
  
  <p><em>Write a shell script that implements a directory size analyzer. In your script you may use common Linux commands. The script should list the disk storage occupied by each immediate subdirectory of a given argument or the current directory (if no argument is given) with the subdirectory names sorted alphabetically. Also, list the name of the subdirectory with the highest disk usage along with its storage size. If more than one subdirectory has the same highest disk usage, list any one of those subdirectories. Include meaningful brief comments. List of bash commands applicable for this script includes the following but not limited: cat, cut, du, echo, exit, for, head, if, ls, rm, sort, tail, wc. You may use bash variables as well as temporary files to hold intermediate results. Delete all temporary files at the end of the execution.</em></p>
  
  <p>Here is my result after entering <code>du $dir -hk --max-depth=2 | sort -o temp1.txt</code> then <code>cat temp1.txt</code> in the command line:</p>
  
  <pre><code>12      ./IT_PLAN/Inter_Disciplinary
  28      ./IT_PLAN
  3       ./IT_PLAN/Core_Courses
  3       ./IT_PLAN/Pre_reqs
  81      .
  9       ./IT_PLAN/IT_Electives
  </code></pre>
  
  <p>It should look like this:</p>
  
  <pre><code>28      ./IT_PLAN
  3       ./IT_PLAN/Core_Courses
  12      ./IT_PLAN/Inter_Disciplinary
  9       ./IT_PLAN/IT_Electives
  The subdirectory with the maximum disk space use:
  28      ./IT_PLAN
  </code></pre>
  
  <p>Once again, I'm having trouble sorting the results alphabetically.</p>