wherewhy

Sort Legend to Match MXD

Discussion created by wherewhy on Nov 28, 2011
I have an MXD with a Layer that is symbolized into unique values based on a type attribute.

Let's say the types are

Apple
Banana
Pear
Strawberry

I have them symbolized in that order in my MXD (alphabetical)

Using the Legend Sample Code from online, when I create the legend and the function
- (void) addLegendForLayer:(AGSLayer *)layer
is called.. the legend swatches and names show up in random order

like

Strawberry
Pear
Apple
Banana

The legend items are in order if I view them through REST, but in the legend, as noted above, they are not.

Can the legend swatches be ordered to match the MXD easily?

Outcomes