I have a query which returns duplicate records. I need to remove all duplicates from it and store all unique records in a list. I'm trying to assign non duplicate records including id to tempList. Please suggest a method to achieve this. Thanks.
Map<String,temp_object__c> tempMap = new Map<String,temp_object__c>([select id,name,string,string1,string2 from temp_object__c]);
List<temp_object__c> tempList = new List<temp_object__c>();
for(String key: tempMap.keyset()){
//here i need to assign to tempList
}