package { import flash.utils.Dictionary; public class professional_flex_code_17_SortedMap { private var map:Dictionary; private var keys:Array; public function professional_flex_code_17_SortedMap() { map = new Dictionary(); keys = new Array(); } // add values by key public function addItem( key:Object, value:Object ):void { map[ key ] = value; keys.push( key ); } // get values by key public function getItem( key:Object ):Object { return map[ key ]; } // return keys array, used to iterator over values public function keySet():Array { // sort keys, use toString() on key keys.sort(); return keys; } // return keys array, used to iterator over values public function values():Array { var values:Array = new Array(); for each( var val:Object in map ) values.push( val ); return values; } } }