转换类型以进行排序:运行时需要任何费用吗?

I'm just getting to grips with Go (started two days ago and wrote less than 1000 lines), and I'm still wondering about some idioms.

I needed to sort a slice of strings by descending length. I did like so :

func ... {
    ... do business ...

    sort.Sort(stringsLongestFirst(severalThousandStrings))

    ... carry on and be happy, because it works ...
}

type stringsLongestFirst []string

func (b stringsLongestFirst) Len() int           { return len(b) }
func (b stringsLongestFirst) Less(i, j int) bool { return len(b[i]) > len(b[j]) }
func (b stringsLongestFirst) Swap(i, j int)      { b[j], b[i] = b[i], b[j] }

First of all I wonder if this is the most idiomatic way to do it.

And then, most of all, I wonder about what happens under the hood when I write stringsLongestFirst(severalThousandStrings). Does the string slice somehow get smartly reinterpreted as a stringsLongestFirst type, or do I have to count with some copying overhead ?

(edited : removed the excerpt from the specification, that was ill-suited to the case at hand)

The types you are converting is neither a numeric type or a string: []string and stringsLongestFirst are slice types.

So the conversion should incur no more overhead than copying the slice header (which is 12 or 24 bytes, depending on the word size), which would happen anyway when packing it as an interface{} variable in order to call Sort. The backing array is not copied, which is why severalThousandStrings appears to be sorted after the call.