I was trying to add case-sensitivity to Yashied's function, but for some reason instead of returning 4 results for the second example it returns 5. What makes this even stranger, is if I change both the guinness items to guinnes (minus the last s) it works!
I tested this on v3.3.8.1 and v3.3.9.4+.
AutoIt
#include <Array.au3> Example_Non_Case_Senstive() Example_Case_Senstive() Func Example_Non_Case_Senstive() Local $aArray[6] = [5, 'guinness', 'GUINNESS', 'GuInNeSs', 'Guinness', 'guinness'] _ArrayUniqueFast($aArray, 1, $aArray[0], False) ; Will return an array with 1 item. _ArrayDisplay($aArray) EndFunc ;==>Example_Non_Case_Senstive Func Example_Case_Senstive() Local $aArray[6] = [5, 'guinness', 'GUINNESS', 'GuInNeSs', 'Guinness', 'guinness'] ; Change guinness to guinnes _ArrayUniqueFast($aArray, 1, $aArray[0], True) ; Will return an array with 4 items. _ArrayDisplay($aArray) EndFunc ;==>Example_Case_Senstive #Obfuscator_Off ; By Yashied. Taken from: http://www.autoitscript.com/forum/topic/122192-arraysort-and-eliminate-duplicates/#entry849187 ; Modified by guinness. Added case-sensitive support. Func _ArrayUniqueFast(ByRef $aArray, $iStart, $iEnd, $fCaseSensitive = Default) ; Default is False. Local Const $iLocalVar = 1 Local $sOutput = '' For $i = $iStart To $iEnd If $fCaseSensitive And Not (Eval($aArray[$i]) == $aArray[$i]) Then Assign($aArray[$i], $aArray[$i], $iLocalVar) ConsoleWrite($aArray[$i] & ': ' & (Eval($aArray[$i]) == $aArray[$i]) & @CRLF) $sOutput &= $aArray[$i] & @CRLF ElseIf Not $fCaseSensitive Then If IsDeclared($aArray[$i]) = 0 Then Assign($aArray[$i], $aArray[$i], $iLocalVar) $sOutput &= $aArray[$i] & @CRLF EndIf EndIf Next $sOutput = StringTrimRight($sOutput, StringLen(@CRLF)) $aArray = StringSplit($sOutput, @CRLF, 1) EndFunc ;==>_ArrayUniqueFast #Obfuscator_On