Warning

This book is new. If you'd like to go through it, then join the Learn Code Forum to get help while you attempt it. I'm also looking for feedback on the difficulty of the projects. If you don't like public forums, then email help@learncodethehardway.org to talk privately.

Exercise 10: sort

You are slowly building up what I call a Personal Process Practice (3P), which isn't a new idea at all. The purpose of your 3P is to gain objective insight into how you do things without killing your creativity and productivity. By simply tracking little metrics and making run charts to guide improvements you can drastically change how well you work. The risk though is that this will prevent you from hacking quickly or getting things done or that your 3P will become more work than your real work.

I did this for about four years of my programming career and it worked great to teach me about myself and how I work. It also cut through many of the lies that process advocates push. I had a simple way to actually test if some pundit's views on programming improved my personal productivity. I would say the only mistake I made was taking it much too seriously and killing my creativity for those four years.

This is why you're building an idea of your starting process and work environment in small quick hacks. You don't have time to collect complicated metrics and worry about exactly how you do things when there's only 45 minutes to get something done. Later we'll focus on practices that require concentration, and you'll spend more time and gather slightly better metrics. As you work try not to let the metrics kill your creativity, flow, or well-being. If you hate collecting something, then don't do it. Find a way to automate it, or come up with another metric.

For this exercise you are making a run chart of your percentage of features completed. This means before you work you'll have to enumerate all the features you can find in the standard man pages for the sort command, then mark how many you completed. Remember to sort them so that you can get enough done such that the tool actually works in some way. Getting a 90% score on a tool that doesn't actually sort text means you actually completed 0%.

When you are done you should make the run chart of your feature percentage completed for each project so we can analyze it in the next exercise.

Exercise Challenge

In this exercise you are implementing the sort command, which is a very simple command. It takes lines of text and simply sorts them in order. It does have quite a few options that are interesting, so you should read the man sort page to find out what it can do. Most of the time people just use sort to sort lists of names in order:

ls | sort

You can also reverse the sort:

ls | sort -r

And you can control how it sorts, such as ignoring case:

ls | sort -f

Or, you can even do sorting numerically instead:

ls | sort -g

This might not really do much to the ls output unless it's all numbers.

Your job is to implement as many of these features as you can and keep track of each feature you complete. This should all be in your lab notes so you can analyze it later.

Study Drills

  1. Are you at a point now where you've run out of things to improve? Try searching around and looking for other people's process suggestions.
  2. We are programmers, people of code. Have you tried to find code that makes you more efficient? My friends Audrey and Danny have a project called cookie-cutter you should check out.
  3. You should now research how to calculate the mean of a set of numbers. You'll be using this to calculate your run chart middle line using Python.

Further Study

If you really want a correct run chart you'll also need to calculate the standard deviation of your numbers. It's not necessary right now but if you want to be technically accurate then this is helpful.

Pre-order Learn More Python The Hard Way

When you pre-order Learn More Python The Hard Way, you'll receive the Python 3 Edition as it's being created. All files are DRM free and you can download them to your computer for offline viewing. Digital Download Only! You do not get a physical book.

$29.00

Buy the Online Course

Or, you can read Learn More Python the Hard Way for free right here, video lectures not included.

Other Buying Options

Other buying options coming soon.

No content available for this exercise. You can view all available downloads at your customer account page.