Sample Video Frame

Created by Zed A. Shaw Updated 2024-02-17 04:54:36

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

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.

Previous Lesson Next Lesson

Register for Learn More Python the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.