What should be the logic of hashfunction() in order to check that two strings are anagrams or not ? : I want to write a function that takes string as a parameter and returns a number corresponding to that string. 

 Integer hashfunction(String a)
    {
        
//logic    
    }

Actually the question im solving is as follows :

Given an array of strings, return all groups of strings that are anagrams. Represent a group by a list of integers representing the index in the original list.

Input : cat dog god tca

Output : [[1, 4], [2, 3]]

Here is my implementation :- 

	public class Solution {
    Integer hashfunction(String a)
    {
        int i=0;int ans=0;
        for(i=0;i<a.length();i++)
        {
            ans+=(int)(a.charAt(i));                //Adding all ASCII values
            
            
        }
        
        return new Integer(ans);
    }
    **Obviously this approach is incorrect**
	public ArrayList<ArrayList<Integer>> anagrams(final List<String> a) {
	    int i=0;
        HashMap<String,Integer> hashtable=new HashMap<String,Integer>();
        ArrayList<Integer> mylist=new ArrayList<Integer>();
        ArrayList<ArrayList<Integer>> answer=new  ArrayList<ArrayList<Integer>>(); 
        if(a.size()==1)
        {
            mylist.add(new Integer(1));
            answer.add(mylist);
            return answer;
            
        }
        
        int j=1;
        for(i=0;i<a.size()-1;i++)
        {   
              
                      hashtable.put(a.get(i),hashfunction(a.get(i)));
            for(j=i+1;j<a.size();j++)
            {
          
                if(hashtable.containsValue(hashfunction(a.get(j))))
                {
                    mylist.add(new Integer(i+1));
                    mylist.add(new Integer(j+1));
                    answer.add(mylist);
                    mylist.clear();
                    
                    
                }
                    
            
                
                
            }
        }
        
    return answer;
	    
	}
}

