 | | bsort-length begins by using inputLine to read in up to NSTRINGS lines of data and storing them in the strings array. The strptrs array points to the strings, so that by rearranging the pointers, you can achieve the sort. After reading in the strings, the bubbleSort function is called. bubbleSort makes several passes through the strings, comparing the lengths of adjacent strings with strlen. When the first string is longer than the second, the pointers to those two strings are exchanged. Finally, when the sort finishes, the strings are printed with outputLine. | |
|