We consider a data-exchange scenario in which each user initially has a subset of packets in the ground set X, and needs to retrieve all other packets in X. The users can exchange their packets by broadcasting coded or uncoded packets over a lossless broadcast channel. We refer to the set of all users as the grand coalition, and refer to any subset of users that collectively hold all packets in X as a minor coalition. A schedule and a scheme for transmissions satisfying all users in a coalition is called a solution for the coalition. The grand coalition is said to be stable under a solution if the following conditions hold: (i) there exists no other solution for any coalition S such that the transmission rate of some (or, respectively, any) member of S is strictly less (or, respectively, not greater) than that under the original solution; and (ii) there exists no other solution for any coalition S such that the sum- rate of S (i.e., the total transmission rate by all users in S) is strictly less (or, respectively, not greater) than the sum-rate of any coalition that includes some given (or, respectively, any arbitrary) member of S under the original solution. Our goal is to identify (if possible) a solution under which the grand coalition is stable. In this work, we propose an algorithm, referred to as cooperative data exchange with stable coalitions (CDESC), that, for any given instance, determines if there exists such a solution, and if so, it finds one such a solution.