<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Sorting an ArrayCollection using the SortField and Sort classes</title>
	<atom:link href="http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: saiyam</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-10331</link>
		<dc:creator>saiyam</dc:creator>
		<pubDate>Thu, 19 Jan 2012 04:51:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-10331</guid>
		<description>Hi!!
i have 2 lists. in the first list i am randomly generating 5 numbers. after that i am moving those through drag and drop in the second list. now when i m calling sort function the first list is sorted instead of the new list..can u help me with the code..??</description>
		<content:encoded><![CDATA[<p>Hi!!<br />
i have 2 lists. in the first list i am randomly generating 5 numbers. after that i am moving those through drag and drop in the second list. now when i m calling sort function the first list is sorted instead of the new list..can u help me with the code..??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahesan R.V(rvmahesan@gmail.com)</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-10272</link>
		<dc:creator>Mahesan R.V(rvmahesan@gmail.com)</dc:creator>
		<pubDate>Sun, 25 Dec 2011 06:19:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-10272</guid>
		<description>in the prev code the sort process did not modifies the main array collection.i accessed via the second data grid it shows only the unsorted array collection.But already sorted the list and then only i accessed tht..wts the reason</description>
		<content:encoded><![CDATA[<p>in the prev code the sort process did not modifies the main array collection.i accessed via the second data grid it shows only the unsorted array collection.But already sorted the list and then only i accessed tht..wts the reason</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahesan R.V(rvmahesan@gmail.com)</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-10271</link>
		<dc:creator>Mahesan R.V(rvmahesan@gmail.com)</dc:creator>
		<pubDate>Sun, 25 Dec 2011 06:16:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-10271</guid>
		<description>

	
		&lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;
		
	
	
		&lt;![CDATA[
			import mx.collections.ArrayCollection;
			import mx.collections.Sort;
			import mx.controls.Alert;
			import mx.controls.DateField;
			import mx.utils.ObjectUtil;
			import mx.utils.object_proxy;
			[Bindable]
			private var arrClldetails:ArrayCollection = new ArrayCollection([
				{Fname:&quot;Kranthi&quot;, Lname:&quot;Kata&quot;, dob:&quot;Sep 21,1978&quot;},
				{Fname:&quot;Vasanth&quot;, Lname:&quot;Lola&quot;, dob:&quot;Jun 11,1979&quot;},
				{Fname:&quot;Manoj&quot;, Lname:&quot;Pati&quot;, dob:&quot;July 12,1980&quot;},
				{Fname:&quot;John McClain&quot;, Lname:&quot;Mela&quot;, dob:&quot;Feb 12,1972&quot;},
				{Fname:&quot;Ross&quot;, Lname:&quot;Geller&quot;, dob:&quot;Jan 02,1973&quot;},
				{Fname:&quot;Chandler&quot;, Lname:&quot;Bing&quot;, dob:&quot;Oct 12,1974&quot;},
				{Fname:&quot;Monica&quot;, Lname:&quot;Geller&quot;, dob:&quot;Mar 30,1976&quot;},
				{Fname:&quot;Racheal&quot;, Lname:&quot;Green&quot;, dob:&quot;Dec 12,1977&quot;},
				{Fname:&quot;Feebe&quot;, Lname:&quot;Bufae&quot;, dob:&quot;Dec 05,1981&quot;},
				{Fname:&quot;Joey&quot;, Lname:&quot;Tribiyani&quot;, dob:&quot;Apr 12,1975&quot;},
				{Fname:&quot;Priya&quot;, Lname:&quot;Katari&quot;, dob:&quot;Mar 31,1982&quot;}
			]);
			private var arrData:ArrayCollection ;
			private function fnClick():void
			{
				
				var sortl:Sort=new Sort();
				sortl.compareFunction=fnCompareFunction;
				
				arrClldetails.sort=sortl;
				
				arrClldetails.refresh();
				//				for (var i:Number=0;i&lt; arrClldetails.length;i++)
				//					mx.controls.Alert.show(arrClldetails[i].Fname);
				arrData=arr_copy(arrClldetails);
				
			}
			private function fnCompareFunction(ObjA:Object,ObjB:Object,fields:Array = null):int
			{
				var dateA:Date=fnDtfParceFunct(ObjA.dob,&quot;MM/DD/YYYY&quot;);
				var dateB:Date=fnDtfParceFunct(ObjB.dob,&quot;MM/DD/YYYY&quot;);
				return ObjectUtil.dateCompare(dateA, dateB);
				
			}
			public function fnDtfParceFunct(valueString:String, inputFormat:String):Date
			{
				return DateField.stringToDate(dateFormatter.format(valueString),inputFormat);
			}
			protected function button1_clickHandler(event:MouseEvent):void
			{
				
				var temp:ArrayCollection= arr_copy(arrClldetails);
				var ss:String=&quot;&quot;;
				for (var ii:Number=0;ii&lt; temp.length;ii++)
					ss += temp[ii].Fname+&quot;\n&quot;;
				mx.controls.Alert.show(ss);
				
				var temp1:ArrayCollection= arr_copy(arrClldetails);
				
				
				
				var ss1:String=&quot;&quot;;
				for(var i:Number=arrClldetails.length-1;i != -1;i--)
				{
					
					arrClldetails[i]= arrClldetails[Math.abs(i - (arrClldetails.length-1))];
					//					ss += &quot;&quot;+Math.abs(i - (temp.length-1))+&quot;\n&quot;;
					//					ss1 += &quot;&quot;+i+&quot;\n&quot;;
					//					ss += arrClldetails[Math.abs(i - (arrClldetails.length-1))].Fname+&quot;\n&quot;;
					//					ss1 += temp[i].Fname+&quot;\n&quot;;
				}
				//				for (var ii:Number=0;ii
	
	
	
	
	
	
	
	
	
		
	
	
	

//in the above code,the sort :cant modify the arrCldet //:wts the reason plz mail me</description>
		<content:encoded><![CDATA[<p><!-- Place non-visual elements (e.g., services, value objects) here --></p>
<p>		&lt;![CDATA[<br />
			import mx.collections.ArrayCollection;<br />
			import mx.collections.Sort;<br />
			import mx.controls.Alert;<br />
			import mx.controls.DateField;<br />
			import mx.utils.ObjectUtil;<br />
			import mx.utils.object_proxy;<br />
			[Bindable]<br />
			private var arrClldetails:ArrayCollection = new ArrayCollection([<br />
				{Fname:&quot;Kranthi&quot;, Lname:&quot;Kata&quot;, dob:&quot;Sep 21,1978&quot;},<br />
				{Fname:&quot;Vasanth&quot;, Lname:&quot;Lola&quot;, dob:&quot;Jun 11,1979&quot;},<br />
				{Fname:&quot;Manoj&quot;, Lname:&quot;Pati&quot;, dob:&quot;July 12,1980&quot;},<br />
				{Fname:&quot;John McClain&quot;, Lname:&quot;Mela&quot;, dob:&quot;Feb 12,1972&quot;},<br />
				{Fname:&quot;Ross&quot;, Lname:&quot;Geller&quot;, dob:&quot;Jan 02,1973&quot;},<br />
				{Fname:&quot;Chandler&quot;, Lname:&quot;Bing&quot;, dob:&quot;Oct 12,1974&quot;},<br />
				{Fname:&quot;Monica&quot;, Lname:&quot;Geller&quot;, dob:&quot;Mar 30,1976&quot;},<br />
				{Fname:&quot;Racheal&quot;, Lname:&quot;Green&quot;, dob:&quot;Dec 12,1977&quot;},<br />
				{Fname:&quot;Feebe&quot;, Lname:&quot;Bufae&quot;, dob:&quot;Dec 05,1981&quot;},<br />
				{Fname:&quot;Joey&quot;, Lname:&quot;Tribiyani&quot;, dob:&quot;Apr 12,1975&quot;},<br />
				{Fname:&quot;Priya&quot;, Lname:&quot;Katari&quot;, dob:&quot;Mar 31,1982&quot;}<br />
			]);<br />
			private var arrData:ArrayCollection ;<br />
			private function fnClick():void<br />
			{</p>
<p>				var sortl:Sort=new Sort();<br />
				sortl.compareFunction=fnCompareFunction;</p>
<p>				arrClldetails.sort=sortl;</p>
<p>				arrClldetails.refresh();<br />
				//				for (var i:Number=0;i&lt; arrClldetails.length;i++)<br />
				//					mx.controls.Alert.show(arrClldetails[i].Fname);<br />
				arrData=arr_copy(arrClldetails);</p>
<p>			}<br />
			private function fnCompareFunction(ObjA:Object,ObjB:Object,fields:Array = null):int<br />
			{<br />
				var dateA:Date=fnDtfParceFunct(ObjA.dob,&quot;MM/DD/YYYY&quot;);<br />
				var dateB:Date=fnDtfParceFunct(ObjB.dob,&quot;MM/DD/YYYY&quot;);<br />
				return ObjectUtil.dateCompare(dateA, dateB);</p>
<p>			}<br />
			public function fnDtfParceFunct(valueString:String, inputFormat:String):Date<br />
			{<br />
				return DateField.stringToDate(dateFormatter.format(valueString),inputFormat);<br />
			}<br />
			protected function button1_clickHandler(event:MouseEvent):void<br />
			{</p>
<p>				var temp:ArrayCollection= arr_copy(arrClldetails);<br />
				var ss:String=&quot;&quot;;<br />
				for (var ii:Number=0;ii&lt; temp.length;ii++)<br />
					ss += temp[ii].Fname+&quot;\n&quot;;<br />
				mx.controls.Alert.show(ss);</p>
<p>				var temp1:ArrayCollection= arr_copy(arrClldetails);</p>
<p>				var ss1:String=&quot;&quot;;<br />
				for(var i:Number=arrClldetails.length-1;i != -1;i&#8211;)<br />
				{</p>
<p>					arrClldetails[i]= arrClldetails[Math.abs(i - (arrClldetails.length-1))];<br />
					//					ss += &quot;&quot;+Math.abs(i &#8211; (temp.length-1))+&quot;\n&quot;;<br />
					//					ss1 += &quot;&quot;+i+&quot;\n&quot;;<br />
					//					ss += arrClldetails[Math.abs(i - (arrClldetails.length-1))].Fname+&quot;\n&quot;;<br />
					//					ss1 += temp[i].Fname+&quot;\n&quot;;<br />
				}<br />
				//				for (var ii:Number=0;ii</p>
<p>//in the above code,the sort :cant modify the arrCldet //:wts the reason plz mail me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-9562</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Fri, 02 Sep 2011 16:52:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-9562</guid>
		<description>@Michelle,

Look at using a custom sort compare function: http://blog.flexexamples.com/2008/04/09/creating-a-custom-sort-on-a-datagrid-control-in-flex/

Peter</description>
		<content:encoded><![CDATA[<p>@Michelle,</p>
<p>Look at using a custom sort compare function: <a href="http://blog.flexexamples.com/2008/04/09/creating-a-custom-sort-on-a-datagrid-control-in-flex/" rel="nofollow">http://blog.flexexamples.com/2008/04/09/creating-a-custom-sort-on-a-datagrid-control-in-flex/</a></p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michelle</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-9561</link>
		<dc:creator>Michelle</dc:creator>
		<pubDate>Fri, 02 Sep 2011 16:33:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-9561</guid>
		<description>I still have not seen anyone answer on how to sort on multiple fields such as firstName and lastName or lastName and firstName.  I have tried it by creating a sortField =  firstName + lastName but if errors out.  I tried creating two sort Fields and sort.Fields = [firstField,lastField] and I have tried sort.Fields = [firstField+lastField].

I have also set numeric = false

All have failed so far.</description>
		<content:encoded><![CDATA[<p>I still have not seen anyone answer on how to sort on multiple fields such as firstName and lastName or lastName and firstName.  I have tried it by creating a sortField =  firstName + lastName but if errors out.  I tried creating two sort Fields and sort.Fields = [firstField,lastField] and I have tried sort.Fields = [firstField+lastField].</p>
<p>I have also set numeric = false</p>
<p>All have failed so far.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nige</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-9539</link>
		<dc:creator>Nige</dc:creator>
		<pubDate>Fri, 26 Aug 2011 14:57:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-9539</guid>
		<description>Much obliged, that was very useful info. Also posters for extra tips.</description>
		<content:encoded><![CDATA[<p>Much obliged, that was very useful info. Also posters for extra tips.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nirmal Kumar Bhogadi</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-9266</link>
		<dc:creator>Nirmal Kumar Bhogadi</dc:creator>
		<pubDate>Fri, 03 Jun 2011 06:28:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-9266</guid>
		<description>Hi,

Is there any way to sort currency values. I have a datagrid column where I show currency values. I get the data in $35.87 format. Can someone help me how to sort these values.

Thanks,
Nirmal Kumar Bhogadi</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Is there any way to sort currency values. I have a datagrid column where I show currency values. I get the data in $35.87 format. Can someone help me how to sort these values.</p>
<p>Thanks,<br />
Nirmal Kumar Bhogadi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JerryW</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-8995</link>
		<dc:creator>JerryW</dc:creator>
		<pubDate>Fri, 25 Feb 2011 16:15:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-8995</guid>
		<description>I ran into the same issue.  A fellow programmer clued me in that you can specify a compareFunction for the Sort object.  In there, you can do your comparisons using your object properties.  Worked like a charm.</description>
		<content:encoded><![CDATA[<p>I ran into the same issue.  A fellow programmer clued me in that you can specify a compareFunction for the Sort object.  In there, you can do your comparisons using your object properties.  Worked like a charm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joel</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-8509</link>
		<dc:creator>joel</dc:creator>
		<pubDate>Mon, 01 Nov 2010 17:05:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-8509</guid>
		<description>thanks for this post...although I could have figured this out in a reasonable amount of time, your post allowed me to achieve my implementation  much faster.</description>
		<content:encoded><![CDATA[<p>thanks for this post&#8230;although I could have figured this out in a reasonable amount of time, your post allowed me to achieve my implementation  much faster.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Jones</title>
		<link>http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/comment-page-1/#comment-7444</link>
		<dc:creator>Michael Jones</dc:creator>
		<pubDate>Tue, 06 Apr 2010 21:33:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/#comment-7444</guid>
		<description>Thanks andrei! I appreciate this tip.</description>
		<content:encoded><![CDATA[<p>Thanks andrei! I appreciate this tip.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

