{"content":{"title":"【以太坊源码go-ethereum阅读】sort.go","body":"```go // Copyright 2018 The go-ethereum Authors\r\n// This file is part of the go-ethereum library.\r\n//\r\n// The go-ethereum library is free software: you can redistribute it and/or modify\r\n// it under the terms of the GNU Lesser General Public License as published by\r\n// the Free Software Foundation, either version 3 of the License, or\r\n// (at your option) any later version.\r\n//\r\n// The go-ethereum library is distributed in the hope that it will be useful,\r\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n// GNU Lesser General Public License for more details.\r\n//\r\n// You should have received a copy of the GNU Lesser General Public License\r\n// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.\r\n\r\npackage accounts\r\n\r\n// AccountsByURL implements sort.Interface for []Account based on the URL field.\r\n// AccountsByURL基于URL字段实现[]帐户的sort.Interface。\r\ntype AccountsByURL []Account\r\n\r\nfunc (a AccountsByURL) Len() int           { return len(a) }\r\nfunc (a AccountsByURL) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }\r\nfunc (a AccountsByURL) Less(i, j int) bool { return a[i].URL.Cmp(a[j].URL) < 0 }\r\n\r\n// WalletsByURL implements sort.Interface for []Wallet based on the URL field.\r\n// WalletsByURL实现了基于URL字段的[]钱包的排序接口。\r\ntype WalletsByURL []Wallet\r\n\r\nfunc (w WalletsByURL) Len() int           { return len(w) }\r\nfunc (w WalletsByURL) Swap(i, j int)      { w[i], w[j] = w[j], w[i] }\r\nfunc (w WalletsByURL) Less(i, j int) bool { return w[i].URL().Cmp(w[j].URL()) < 0 }\r\n\r\n```"},"author":{"user":"https://learnblockchain.cn/people/14154","address":null},"history":null,"timestamp":1685401806,"version":1}