Is there a Order Map in the lift ?

View: New views
3 Messages — Rating Filter:   Alert me  

Is there a Order Map in the lift ?

by Neil.Lv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi all,

  Is there a Order Map in the lift ?

  Example:
   1-> "xx", 2 -> "yy", 3 -> "zz"

   1:) add 1-> "xx"
   Map(1-> "xx")

   2:) add 3 -> "zz"
   Map(3 -> "zz", 1-> "xx")

   3:) add 2 -> "yy"
   Map(2 -> "yy", 3 -> "zz", 1-> "xx")

   The result maybe: Map(2 -> "yy", 3 -> "zz", 1-> "xx")

    But i want the structure(order by the number) is :  Map(1-> "xx",
2 -> "yy", 3 -> "zz")

   Any help would be much appreciated !

Cheers,
  Neil
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is there a Order Map in the lift ?

by Neil.Lv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


  It works now !

  I use the m.toList.sort(_ < _) method to sort the result.

###
scala> var m = Map(2 -> "yy", 3 -> "zz", 1-> "xx")
scala> m.toList.sort(_ < _)
res149: List[(Int, java.lang.String)] = List((1,xx), (2,yy), (3,zz))
###

  :)

Cheers,
  Neil


On Nov 9, 3:59 pm, "Neil.Lv" <anim...@...> wrote:

> Hi all,
>
>   Is there a Order Map in the lift ?
>
>   Example:
>    1-> "xx", 2 -> "yy", 3 -> "zz"
>
>    1:) add 1-> "xx"
>    Map(1-> "xx")
>
>    2:) add 3 -> "zz"
>    Map(3 -> "zz", 1-> "xx")
>
>    3:) add 2 -> "yy"
>    Map(2 -> "yy", 3 -> "zz", 1-> "xx")
>
>    The result maybe: Map(2 -> "yy", 3 -> "zz", 1-> "xx")
>
>     But i want the structure(order by the number) is :  Map(1-> "xx",
> 2 -> "yy", 3 -> "zz")
>
>    Any help would be much appreciated !
>
> Cheers,
>   Neil
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is there a Order Map in the lift ?

by bearfeeder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

scala.collection.SortedMap

On Sun, Nov 8, 2009 at 11:59 PM, Neil.Lv <anim510@...> wrote:

Hi all,

 Is there a Order Map in the lift ?

 Example:
  1-> "xx", 2 -> "yy", 3 -> "zz"

  1:) add 1-> "xx"
  Map(1-> "xx")

  2:) add 3 -> "zz"
  Map(3 -> "zz", 1-> "xx")

  3:) add 2 -> "yy"
  Map(2 -> "yy", 3 -> "zz", 1-> "xx")

  The result maybe: Map(2 -> "yy", 3 -> "zz", 1-> "xx")

   But i want the structure(order by the number) is :  Map(1-> "xx",
2 -> "yy", 3 -> "zz")

  Any help would be much appreciated !

Cheers,
 Neil




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---