An important number of academic tasks should be solved collaboratively by groups of learners. The Computer-Supported Collaborative Learning (CSCL) systems support this collaboration by means of shared workspaces and tools that enable communication and coordination between learners. Successful collaboration and interaction can depend on the criteria followed when forming the groups of learners. This paper proposes a method that analyses the collaboration and interaction between learners using a set of indicators or variables about how they solve academic tasks. Then, the concept of data depth is used as a measurement of the closeness of the analysis indicators' values for a learner with respect to the values that the same indicators take for the other learners. Finally, the data depth is used to form new groups of learners whose analysis indicators take similar or different values. Thus, the method enables teachers to form homogeneous and heterogeneous groups according to their preferences. This group formation process is carried out automatically by a software tool. This paper presents two case studies in which the method is applied to form groups of learners who solve academic tasks in different domains (computer programming and data mining). (C) 2014 Elsevier Ltd. All rights reserved.