我有一个[]byte我需要按升序排序。
我得到一个包含项目的对象,然后迭代数组以创建返回的对象:
// unfortunately, for some obscure reason I can't change the data types of the caller and the object from the function call are different, although both are []byte underneath (...)
type ID []byte
// in another package:
type ByteInterface []byte
func (c *Store) GetAll() ByteInterface {
returnObj := make([]ByteInterface,0)
obj, err := GetData()
// err handling
for _, b := range obj.IDs {
returnObj = append(returnObj, ByteInterface(b))
}
return returnObj
}
所以我问自己是否有可能立即进行排序,或者我是否需要预先排序append(或事后排序)。returnObjobj.ByteDatareturnOjb
慕工程0101907
相关分类