-
-
Save tunesmith/918b73f9f152b8fb255416cc9427d66a to your computer and use it in GitHub Desktop.
Sort a list of ips in Scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List("129.95.30.40","5.24.69.2","19.20.203.5","1.2.3.4","19.20.21.22","5.220.100.50"). | |
| map(_.split('.').map(_.toInt)). | |
| map( { case Array(x1,x2,x3,x4) => (x1,x2,x3,x4) } ).sorted. | |
| map { case (x1,x2,x3,x4) => "%s.%s.%s.%s".format(x1,x2,x3,x4)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment