Underwater acoustic sensor networks (UASNs) are important technical means to explore the ocean realm. As a strategic measure, clustering techniques balance the network energy and survival time obviously. This paper proposes a clustering algorithm for UASNs. First, an UASN structure of hierarchical 3D mesh is defined, and an energy consumption model is built. Second, the algorithm based on the designed framework is presented, including the basic clustering messages, the setup phase and the data transmission phase. Finally, experiment of the algorithm based on WOSS and MATLAB is implemented, and compared with DS-VBF, IAR, and GEDAR in terms of the average end-to-end delay, the survival rate, the number of survival nodes, the number of clusters, and the coverage ratio. Results demonstrate that a tradeoff between clustering performance and network survival is achieved and the algorithm is suitable for UASNs.