Skip to content

Commit 8dea57d

Browse files
committed
Ignore link info when sorting links.
1 parent 634761b commit 8dea57d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

mininet/topo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@ def links( self, sort=False, withKeys=False, withInfo=False ):
203203
withInfo: return link info
204204
returns: list of ( src, dst [,key, info ] )"""
205205
links = list( self.iterLinks( withKeys, withInfo ) )
206-
return links if not sort else self.sorted( links )
206+
if not sorted:
207+
return links
208+
# Ignore info when sorting
209+
tupleSize = 3 if withKeys else 2
210+
return sorted( links, key=( lambda l: naturalSeq( l[ 0 : tupleSize ] ) ) )
207211

208212
# This legacy port management mechanism is clunky and will probably
209213
# be removed at some point.

0 commit comments

Comments
 (0)