L8.6 MAP type sorting strange

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

L8.6 MAP type sorting strange

Marc Vos
Hello,

I have a problem with MAP. [Lasso 8.6, OS X]

This code:

$p_LABELS = map;
$p_LABELS->insert('F08567' = '1User ID');
$p_LABELS->insert('F1943' = '2Application ID');
$p_LABELS->insert('F25961' = '3Preferences');
$p_LABELS->insert('F39342' = '4Valid Until');
$p_LABELS->insert('F46322' = '5Application Authorisation');

results in this map:

map: (F1943)=(2Application ID), (F46322)=(5Application Authorisation), (F08567)=(1User ID), (F25961)=(3Preferences), (F39342)=(4Valid Until)

which sucks.

It is not sorted by key: F1943, F46322, F08567, F25961, F39342

It is not sorted by the array values: 1..., 2..., 3..., 4..., 5....

and what is worst, it is not in the order in which I inserted the values.

Does someone know what is going on here?

- -
Marc

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 MAP type sorting strange

Jolle Carlestam-3
I know. Maps are not sorted. And there's no way you can change that. If you want it in the order you inserted items use array. If you want it to be guaranteed unique values and sorted use set.

HDB
Jolle

Sent from a mobile device. Any anomalies is due to Autocorrect.

3 okt 2012 kl. 07:05 skrev "Marc Vos" <[hidden email]>:

> Hello,
>
> I have a problem with MAP. [Lasso 8.6, OS X]
>
> This code:
>
> $p_LABELS = map;
> $p_LABELS->insert('F08567' = '1User ID');
> $p_LABELS->insert('F1943' = '2Application ID');
> $p_LABELS->insert('F25961' = '3Preferences');
> $p_LABELS->insert('F39342' = '4Valid Until');
> $p_LABELS->insert('F46322' = '5Application Authorisation');
>
> results in this map:
>
> map: (F1943)=(2Application ID), (F46322)=(5Application Authorisation), (F08567)=(1User ID), (F25961)=(3Preferences), (F39342)=(4Valid Until)
>
> which sucks.
>
> It is not sorted by key: F1943, F46322, F08567, F25961, F39342
>
> It is not sorted by the array values: 1..., 2..., 3..., 4..., 5....
>
> and what is worst, it is not in the order in which I inserted the values.
>
> Does someone know what is going on here?
>
> - -
> Marc
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 MAP type sorting strange

Marc Vos
But there must be some system behind the insertion, because on every reload of the page, the items in the map stay on the the same, wrong place.

- -
Marc

On 2 okt. 2012, at 23:09, Jolle Carlestam <[hidden email]> wrote:

> I know. Maps are not sorted. And there's no way you can change that. If you want it in the order you inserted items use array. If you want it to be guaranteed unique values and sorted use set.
>
> HDB
> Jolle
>
> Sent from a mobile device. Any anomalies is due to Autocorrect.
>
> 3 okt 2012 kl. 07:05 skrev "Marc Vos" <[hidden email]>:
>
>> Hello,
>>
>> I have a problem with MAP. [Lasso 8.6, OS X]
>>
>> This code:
>>
>> $p_LABELS = map;
>> $p_LABELS->insert('F08567' = '1User ID');
>> $p_LABELS->insert('F1943' = '2Application ID');
>> $p_LABELS->insert('F25961' = '3Preferences');
>> $p_LABELS->insert('F39342' = '4Valid Until');
>> $p_LABELS->insert('F46322' = '5Application Authorisation');
>>
>> results in this map:
>>
>> map: (F1943)=(2Application ID), (F46322)=(5Application Authorisation), (F08567)=(1User ID), (F25961)=(3Preferences), (F39342)=(4Valid Until)
>>
>> which sucks.
>>
>> It is not sorted by key: F1943, F46322, F08567, F25961, F39342
>>
>> It is not sorted by the array values: 1..., 2..., 3..., 4..., 5....
>>
>> and what is worst, it is not in the order in which I inserted the values.
>>
>> Does someone know what is going on here?
>>
>> - -
>> Marc
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso
>> [hidden email]
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 MAP type sorting strange

fletcher sandbeck-2
On Oct 2, 2012, at 2:16 PM, [hidden email] wrote:

> But there must be some system behind the insertion, because on every reload of the page, the items in the map stay on the the same, wrong place.

The details have changed from version to version, but it uses some kind of hash or binary sort to find elements.  They are stored in the order which ensures fastest access.

[fletcher]

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 MAP type sorting strange

Wade Maxfield
In reply to this post by Jolle Carlestam-3
On 3/10/2012, at 10:09 AM, Jolle Carlestam <[hidden email]> wrote:

> I know. Maps are not sorted. And there's no way you can change that. If you want it in the order you inserted items use array. If you want it to be guaranteed unique values and sorted use set.
>
> HDB
> Jolle
>


And if you want the random access of a Map, but the order preservation of an Array, then you can use both simultaneously by storing the key in an array and both the key and data in a map as you are already.

 - Wade


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 MAP type sorting strange

Marc Vos
In reply to this post by fletcher sandbeck-2
Ah, that explains the two alphabetic sorts inside the map: F1... and F4..., F0..., F2... and F3....

- -
Marc


On 2 okt. 2012, at 23:19, Fletcher Sandbeck <[hidden email]> wrote:

> On Oct 2, 2012, at 2:16 PM, [hidden email] wrote:
>
>> But there must be some system behind the insertion, because on every reload of the page, the items in the map stay on the the same, wrong place.
>
> The details have changed from version to version, but it uses some kind of hash or binary sort to find elements.  They are stored in the order which ensures fastest access.
>
> [fletcher]
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 MAP type sorting strange

Jolle Carlestam-3
In reply to this post by fletcher sandbeck-2
Further, it so happens that maps in lasso 9 looks to be sorted. But as Fletcher points out, that can change with a different implementation in future versions. So don't count on it in your coding.

HDB
Jolle

Sent from a thin, flat, touchy device from an undetermined place in space.

3 okt 2012 kl. 07:20 skrev "Fletcher Sandbeck" <[hidden email]>:

> On Oct 2, 2012, at 2:16 PM, [hidden email] wrote:
>
>> But there must be some system behind the insertion, because on every reload of the page, the items in the map stay on the the same, wrong place.
>
> The details have changed from version to version, but it uses some kind of hash or binary sort to find elements.  They are stored in the order which ensures fastest access.
>
> [fletcher]
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 MAP type sorting strange

Marc Vos
In reply to this post by Wade Maxfield
Good tip! That's the quickest remedy and has the least 'source change'-impact for me.

- -
Marc

On 2 okt. 2012, at 23:21, Wade Maxfield <[hidden email]> wrote:

> On 3/10/2012, at 10:09 AM, Jolle Carlestam <[hidden email]> wrote:
>
>> I know. Maps are not sorted. And there's no way you can change that. If you want it in the order you inserted items use array. If you want it to be guaranteed unique values and sorted use set.
>>
>> HDB
>> Jolle
>>
>
>
> And if you want the random access of a Map, but the order preservation of an Array, then you can use both simultaneously by storing the key in an array and both the key and data in a map as you are already.
>
> - Wade
>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 MAP type sorting strange

Marc Vos
In reply to this post by Jolle Carlestam-3
Everytime I discuss something on the internet, I realize how amazing I find it to get reactions from all parts of the world! I somehow makes me feel good :-)

- -
Marc


On 2 okt. 2012, at 23:26, Jolle Carlestam <[hidden email]> wrote:

> Further, it so happens that maps in lasso 9 looks to be sorted. But as Fletcher points out, that can change with a different implementation in future versions. So don't count on it in your coding.
>
> HDB
> Jolle
>
> Sent from a thin, flat, touchy device from an undetermined place in space.
>
> 3 okt 2012 kl. 07:20 skrev "Fletcher Sandbeck" <[hidden email]>:
>
>> On Oct 2, 2012, at 2:16 PM, [hidden email] wrote:
>>
>>> But there must be some system behind the insertion, because on every reload of the page, the items in the map stay on the the same, wrong place.
>>
>> The details have changed from version to version, but it uses some kind of hash or binary sort to find elements.  They are stored in the order which ensures fastest access.
>>
>> [fletcher]
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso
>> [hidden email]
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>