I have the following function to return sorted dictionary but I'm getting this error:
Cannot convert value of type [(key:string,value:int)] to specified type Dictionary<String,Int>
Here is my code:
func generatDictionaryFromString(str:String) -> Dictionary<String,Int>{
var charDict = Dictionary<String,Int>()
/* doing something here
*/
return charDict.sorted(by:<) // <-- line with the error
}
Does anyone know why I'm getting this error?