English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

1 answers

Assign an order number to each instruction. If it is a database of instructions, you add an order column, if it is a text file you just add a number to the end.

The idea here is that when you pull the lines, you then sort based on that column. This allows you to show them in order or even in backwards order if you like.

I usually accomplish this by pulling the lines into an array which has many sort functions depending on the language. You can then sort the array on that column. When you add one you take the highest order number in the file/table and add one to it. When you delete, you remove that instruction and either resequence all the lines or you can usually leave it as is since it won't break the ordering when you sort on the column.

Some tricks to watch out for, depending on the language, is that your order column is an integer and not a string since strings sometimes do not get sorted properly. Like 2 and 20 are next to one another because of the sort being on a 2 as a character and not a number.

Hope this helps you out! Enjoy and good luck with the widget.

2006-10-30 07:13:48 · answer #1 · answered by Martyr2 7 · 1 0

fedest.com, questions and answers