Taking long list of repeated values and copying to sorted, unique list

numbers

Alrighty, I’m working on some homespun financial rejiggering. I have a manually-entered “Keyword” column that features many repeated values.

A small sampling:

  • Cleaners
  • Cleaners
  • Cleaners
  • Cell
  • Cell
  • Cell
  • Cell
  • Cell
  • Cable
  • Cable
  • Cable
  • Cable
  • Band
  • Band
  • ATM Fee
  • ATM Fee
  • ATM Fee
  • ATM Fee
  • ATM Fee
  • ATM Fee
  • Amazon
  • Amazon
  • Amazon
  • Amazon
  • Amazon
  • Amazon
  • Amazon

I need to create either another column OR table that takes these many values, de-dupes them and sorts them alphabetically, like this:

  • Cleaners
  • Cell
  • Cable
  • Band
  • ATM Fee
  • Amazon

This needs to be done with formula… not manually or scripted.

Suggestions??

Best Answer

This AppleScript uses terms from the AppleScript Toolbox plug-in to function correctly.

I copied your list of duplicates and pasted them between the double quotes in the first line of my code

set theList to paragraphs of "Cleaners\nCleaners\nCleaners\nCell\nCell\nCell\nCell\nCell\nCable\nCable\nCable\nCable\nBand\nBand\nATM Fee\nATM Fee\nATM Fee\nATM Fee\nATM Fee\nATM Fee\nAmazon\nAmazon\nAmazon\nAmazon\nAmazon\nAmazon\nAmazon"
set noDupes to AST copy list theList with sorting items without keeping duplicates
set text item delimiters to {linefeed}
set theList2 to noDupes as text
set theList2 to reverse of paragraphs of theList2
set the clipboard to theList2 as text

Will return A new list without the duplicates and copy it to your clipboard:

  • Cleaners
  • Cell
  • Cable
  • Band
  • ATM Fee
  • Amazon