aArray->Clear(); for (i = 0; i < count; i++) { aArray->AppendElement(array[i]);
aArray->Clear(); for (i = 0; i < count; i++) { aArray->AppendElement(array[i].item); }
nsresult nsCharsetMenu::ReorderMenuItemArray(nsVoidArray * aArray){  nsresult res = NS_OK;  nsCOMPtr<nsICollation> collation;  PRUint32 count = aArray->Count();  PRUint32 i;  // we need to use a temporary array  nsMenuItem ** array = new nsMenuItem * [count];  if (array == NULL) {    res = NS_ERROR_OUT_OF_MEMORY;    goto done;  }  for (i = 0; i < count; i++) {    array[i] = (nsMenuItem *)aArray->ElementAt(i);  }  // reorder the array  res = GetCollation(getter_AddRefs(collation));  if (NS_SUCCEEDED(res))     NS_QuickSort(array, count, sizeof(*array), CompareMenuItems, collation);  // move the elements from the temporary array into the the real one  aArray->Clear();  for (i = 0; i < count; i++) {    aArray->AppendElement(array[i]);  }done:  delete [] array;  return res;}