What script can I use to sort a string of labels to display every third or forth label?

Mapping Center Answer:

I am not sure exactly what the "order" for your data is based on, but we have seen the same sort of thing for contours when you need to label every 5th contour with an index value (bolder font) and all others with an intermediate value (lighter weight font). So the way to do this is to add a field to the attribute table of the feature class you want to label – we often call it LabelYN and make it a boolean attribute. If we make it a Text field, then the attributes will be "Y" for "Yes, label this feature", or "N" for "No, don't label it". Or you can use a short integer field with 1 for "Yes, label this feature" and 0 for "No, don't label it".

You can also do the same with an attribute to determine if you want to SHOW a feature. In this case, we often call the attribute "ShowYN".

Then you need to calculate the values for the field. Assuming you use the short integer field definition, you can edit the attached calculate statement in ArcGIS 10 as a Python statement (you can change from VB to Python by clicking the Python option at the of the Field Calculator dialog) after loading this cal expression in the Field Calculator.

This cal statement was set up to calculate the value in the ShowYN field to equal 1 for every 40 foot contour and 0 for all other contours. It looks like this:

Where ELEVATION in the k = Right( Str( [ELEVATION_] ),3 ) line is the field from which I am choosing the values that will be labeled or not; 3 in the k = Right( Str( [ELEVATION_] ),3 ) line specifies that only the last three digits of the ELEVATION value will be evaluated, and 40, 80, 120, 160 and 000 in the elseif lines are the values that will be selected.

You can modify these statement parameters for your own needs, specifying the attribute that you will determine the “order” from, which digits within that value will be evaluated and which values of those digits will result in an attribute of 0 or "Yes".

Then using a definition query for the ShowYN option or a SQL query for the LabelYN option, you can set up the instances in whcih you will or will not show or label your features.