我想實現冒泡排序到我的劇本,讓我整理我的數據字母。Perl的排序援助
**NetworkManager** Nov 8 13:24:23 osboxes <info> disable requested (sleeping: no enabled: yes) NetworkManager[1249]:
**dhclient** Nov 8 15:52:45 osboxes DHCPOFFER of 192.168.253.129 from 192.168.253.254 dhclient:
**dhclient** Nov 8 15:52:45 osboxes DHCPACK of 192.168.253.129 from 192.168.253.254 dhclient:
**dnsmasq** Nov 13 17:52:35 osboxes using nameserver 192.168.253.2#53 dnsmasq[1637]:
這就是文件的樣子,所以讀取文件,然後將其存儲到數組中。
我希望能夠用什麼數據字母在開始進行排序(在**),所以輸出應該是這樣的:
**dhclient** Nov 8 15:52:45 osboxes DHCPOFFER of 192.168.253.129 from 192.168.253.254 dhclient:
**dhclient** Nov 8 15:52:45 osboxes DHCPACK of 192.168.253.129 from 192.168.253.254 dhclient:
**dnsmasq** Nov 13 17:52:35 osboxes using nameserver 192.168.253.2#53 dnsmasq[1637]:
**NetworkManager** Nov 8 13:24:23 osboxes <info> disable requested (sleeping: no enabled: yes) NetworkManager[1249]:
爲什麼冒泡排序,而不是僅僅使用Perl的內置'sort'功能?你到目前爲止有什麼? – Tanktalus
也許是因爲任務這麼說? :) – simbabque
我認爲@Tanktalus提出的問題是有效的。爲什麼不使用需要幾乎零工作並且性能可能更好的解決方案? –