Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell hash order inside a function

$
0
0

Hello everyone,

I have a hashtable that i pass inside a function

the hashtable is ordered .

$hash2= [ordered]@{}


the keys are date and are formatted like this : 25/05/2013

this is the output of my $hash2 :

Name                           Value
----                           -----
17/05/2013                     5886
18/05/2013                     1085
19/05/2013                     865
20/05/2013                     1445
21/05/2013                     6313
22/05/2013                     5650
23/05/2013                     6088
24/05/2013                     6685
25/05/2013                     1178
26/05/2013                     1016
27/05/2013                     7191
28/05/2013                     6553
29/05/2013                     5861
30/05/2013                     6172
31/05/2013                     5619
01/06/2013                     967
02/06/2013                     922
03/06/2013                     6341


so there are many date, and they are correctly ordered.

the function i wrote take the hashtable as a paramater :

function hop-hash{
param(    [Hashtable]$hash
)
$hash
}

but inside the function the hash is not ordered anymore !

Name                           Value
----                           -----
19/05/2013                     865
01/06/2013                     967
29/05/2013                     5861
06/06/2013                     5922
04/06/2013                     6588
14/06/2013                     6006
13/06/2013                     6407
17/05/2013                     5886
31/05/2013                     5619
27/05/2013                     7191
16/06/2013                     1131
08/06/2013                     988
21/05/2013                     6313
22/05/2013                     5650
30/05/2013                     6172
26/05/2013                     1016
05/06/2013                     6723
03/06/2013                     6341

I need it to be ordered because i'm generating some graph inside my real function so ...

can someone explain me why this is happening ? and what i doing wrong ? or maybe how i can resolve this problem !


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>