protected override MutableObject Mutate(MutableObject mutable)
        {
            var groupId = GroupId.GetFirstValue(mutable);

            Dictionary <T, int> localShare;

            if (groupId != "")
            {
                if (!DataShare.ContainsKey(groupId))
                {
                    DataShare.Add(groupId, new Dictionary <T, int>());
                }

                localShare = DataShare[groupId];
            }
            else
            {
                localShare = new Dictionary <T, int>();
            }

            foreach (var entry in AxisKey.GetEntries(mutable))
            {
                var key = AxisKey.GetValue(entry);

                if (!localShare.ContainsKey(key))
                {
                    localShare[key] = 0;
                }

                IndexAxis.SetValue(localShare[key], entry);
                localShare[key]++;
            }

            return(mutable);
        }
        protected override void OnProcessOutputSchema(MutableObject newSchema)
        {
            var entryList = AxisKey.GetEntries(newSchema);

            foreach (var entry in entryList)
            {
                IndexAxis.SetValue(0, entry);
            }

            Router.TransmitAllSchema(newSchema);
        }
        protected override MutableObject Mutate(MutableObject mutable)
        {
            var entries = AxisKey.GetEntries(mutable);

            var foundStrings = new HashSet <T>();

            // identify the set of unique keys
            foreach (var entry in entries)
            {
                var axisKey = InputStack.TransformValue(AxisKey.GetValue(entry));

                if (!foundStrings.Contains(axisKey))
                {
                    foundStrings.Add(axisKey);
                }
            }

            // DO NOT sort the keys
            //var sortedKeys = foundStrings.ToList();
            //sortedKeys.Sort();

            // index the values
            var axisValues = GroupId.GetFirstValue(mutable) == "" ?
                             new Dictionary <T, int>()
                : DataShare.ContainsKey(GroupId.GetFirstValue(mutable)) ?
                             DataShare[GroupId.GetFirstValue(mutable)]
                : new Dictionary <T, int>();

            int i = 0;

            foreach (var key in foundStrings) //sortedKeys
            {
                axisValues[key] = OutputStack.TransformValue(i++);
            }

            // finally, write the new axis value into each entry
            entries = AxisKey.GetEntries(mutable);
            foreach (var entry in entries)
            {
                IndexAxis.SetValue(
                    axisValues[InputStack.TransformValue(AxisKey.GetValue(entry))],
                    entry);
            }

            if (GroupId.GetFirstValue(mutable) != "")
            {
                DataShare[GroupId.GetFirstValue(mutable)] = axisValues;
            }

            return(mutable);
        }