@Override
    public void reduce(LongWritable key, Iterable<Text> values, Context context)
    throws IOException, InterruptedException{
		
	          Text finalResult = new Text();
              StringBuffer firstlastOrderIdDate=null;
              StringBuffer order_id=null;
              StringBuffer order_date=null;
              for(Text value:values){
            	  
            	  String[] tokens=value.toString().split("\t");
            	  for(int i=0;i<tokens.length;i++){
    	          String[] id_date_tokens=value.toString().split(",");
    	          
    	          order_id = new StringBuffer(id_date_tokens[0]);
                  order_date = new StringBuffer(id_date_tokens[1]);
                  if(firstlastOrderIdDate==null)
                  firstlastOrderIdDate=new StringBuffer(order_id.toString()+","+order_date.toString());      
                  else
                	  firstlastOrderIdDate.append("\t"+order_id.toString()+","+order_date.toString());
            	  }
            	  
              }
    	          
            StringBuffer stringBuffer = new StringBuffer(key.toString());
              
            int i=0;
    		int j=0;
    		String lastorder_date="0000-00-00";
    		String firstorder_date="2050-00-00";
    		String id=null;
    		String lastorder_id_date="";
    		String firstorder_id_date="";
    		String val=firstlastOrderIdDate.toString();
    		
    		StringTokenizer st=new StringTokenizer(val,"\t");
    		while(st.hasMoreElements()) {
    				String temp=st.nextToken();
    				
    				StringTokenizer st1=new StringTokenizer(temp,",");
    					while(st1.hasMoreElements()) {
    						String temp1=st1.nextToken();
    						j++;
    						if(j==1) {id=temp1; }
    						if(j==2) { 
    								i=lastorder_date.compareTo(temp1); 
    								if(i<0) {
    									lastorder_date=temp1;
    									lastorder_id_date=id+"\t"+temp1;
    								}
    								
    								i=firstorder_date.compareTo(temp1); 
    								if(i>0) {
    									firstorder_date=temp1;
    									firstorder_id_date=id+"\t"+temp1;
    								}
    						}
    					}
    				j=0;
    		}
            stringBuffer.append("\t"+firstorder_id_date+"\t"+lastorder_id_date);
            finalResult.set(stringBuffer.toString());
            context.write(NullWritable.get(), finalResult);
     }